Skip to content
  • home
  • portfolio
  • web design journal
  • blog
    • adventure
    • san diego
    • projects
    • website design
    • code notes
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

drempd | san diego, ca


home contact

adventures san diego projects stream website design

portfolio resume san diego web design freelance web designer

custom web design responsive web design website maintenance