ericf / express-handlebars

A Handlebars view engine for Express which doesn't suck.
BSD 3-Clause "New" or "Revised" License
2.31k stars 384 forks source link

how to access parent variable in #each that in partials? #196

Open lambdaxs opened 7 years ago

lambdaxs commented 7 years ago
res.render('index',{
  list:[{
    color:'red'
},{
    color:'white'
}],
  name:'tom'
})

//index.hbs
{{#each list}}
{{> template}}
{{/each}}

//template.hbs (in partials dir)
<h5>{{color}} {{../name}}</h5>

//result html
<h5>red</h5>
<h5>white</h5>

//can not access parent value 'tom' \(^o^)/~
n-dragon commented 7 years ago

Same issue ! did you have any news ?