Skip to content
  • home
  • portfolio
  • web design journal
  • blog
    • adventure
    • san diego
    • projects
    • website design
Blog Web Dev Reference a Variable Outside of a Handlebars Each Loop

Reference a Variable Outside of a Handlebars Each Loop

By Forrest Smith - Drempd.com

Once within an Handlebars each loop, you can no longer just reference a variable that is outside the loop.  In the example below, the first ‘ParentVariable’ will render correctly, but the one within the “each” loop won’t. 

{{ParentVariable}}
{{#each Users}}
     {{ParentVariable}}
{{/each}}

To use the variable within the “each” block, you’ll need to add a “../” before the variable to reference it:

{{ParentVariable}}
{{#each Users}}
     {{../ParentVariable}}
{{/each}}
Posted on November 17, 2016August 26, 2022 in Web Dev
  • Adventure

    • adventure
    • gravelgrinding
    • hiking
    • running
  • The Built Environment

    • architecture
    • urbanity
  • Locations

    • san diego
    • portland
  • Freelance Life

    • freelancing
    • productivity
  • Web Dev

    • css
    • entrepreneurship
    • git
    • handlebars
    • html
    • inkscape
    • photoshop
    • php
    • sass
    • web design
    • web development
    • saphire

drempd | san diego, ca


home contact

adventures san diego urbanity and architecture projects stream website design

portfolio resume san diego web design freelance web designer

custom web design responsive web design website maintenance