When I loop through an object, example
{{#each personas}}
<h1>{{nombre}}<h1>
{{/each}}
It works perfectly, but if I want to add another variable that doesn't belong to the object I loop through, it simply ignores it and sends me an "undefined"
<p>{{data.info}}<p> <!-- Me muestra la información correctamente -->
{{#each personas}}
<h1>{{nombre}}<h1>
<p>{{data.info}}<p> <!-- Me muestra un "undefined"-->
{{/each}}
How can I render that variable?
Use
{{../data.info}}
.Using the helper
#each
changes the context against which expressions are evaluated. By putting../
at the beginning of the expression you can refer to the parent context. This is explained in the documentation (English), from which I translate this snippet: