Access parent variable from nested block in JsRender -
how can access props
's key
nested for
?
{{props object.items}} {{:key}} {{for prop.other_items}} {{:key}} //here want print key props
i've tried:
{{:key}} {{:#key}} {{:#parent.key}} {{:#parent.parent.key}} {{:~root.key}}
here 3 alternative ways:
provide key
contextual template variable, available in {{for}}
block:
{{props object.items}} {{:key}} {{for prop.other_items ~outerkey=key}} outer key: {{:~outerkey}} {{/for}} {{/props}}
provide data item of {{props}}
block (the {key: ..., prop: ...}
object) contextual template variable, available in {{for}}
block:
{{props object.items itemvar="~outerprop"}} {{:key}} {{for prop.other_items}} outer key: {{:~outerprop.key}} {{/for}} {{/props}}
step through parent views (array view, props item view) , data item (the {key: ..., prop: ...}
object):
{{props object.items}} {{:key}} {{for prop.other_items}} outer key: {{:#parent.parent.data.key}} {{/for}} {{/props}}
and here link related reply previous question matias: https://stackoverflow.com/a/31362057/1054484
Comments
Post a Comment