Answer the question
In order to leave comments, you need to log in
How to access a property in the jsrender template engine in a loop?
JS:
renderHtml(context) {
let template = this._getTemplate();
template
.then(tmpl => {
const shopsTmpl = jsrender.templates(tmpl);
const html = shopsTmpl.render({selectors: this.selectors, context: context});
document.querySelector(this.mainSelector).innerHTML = html;
})
.catch(err => console.log(err));
}
<ul class="list-group">
{{for context}}
<li class="{{:selectors:listItemClass}} {{:context:status}}" data-shopId="{{:context:id}}">
{{:context:name}}
</li>
{{/for}}
</ul>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question