spacebars - Meteor: nested templates and a pseudo switch conditional -
i'm new meteor , @ moment i'm testing out nested templates. more specific, i'm trying pseudo switch working.
i have parent template gets data template.helper function gets data {{#each}}.
this parent template
<template name="result"> {{#each tresult}} <div class="jow"> <h3>{{name}}</h3> <p>{{type}}</p> <div>{{> tstatus}}</div> </div> {{/each}} </template>
the parent includes template {{> tstatus}}
this child template
<template name="tstatus"> {{#status_is "green"}} {{> tstatus_green}} {{/status_is}} {{#status_is "red"}} {{> tstatus__red}} {{/status_is}} {{#status_is "orange"}} {{> tstatus__orange}} {{/status_is}} </template> <template name="tstatus_green"> <span>green</span> </template> <template name="tstatus_red"> <span>red</span> </template> <template name="tstatus_orange"> <span>orange {{number}}</span> </template>
this template can include 3 other templates:
- tstatus_green
- tstatus_red
- tstatus_orange
but problem is, how pseudo switch working. need include 1 of 3 templates, based on it's status color.
and helper function parent template
template.result.helpers({ tresult:function(){ return ttable.find() } })
i this:
template.tstatus.helpers({ getstatuscolor:function() { //"this" current ttable document var color = getcolorfunction(this) return template["tstatus_"+color] } }) <template name="tstatus"> {{#with getstatuscolor}} {{>.}} {{/with}} </template>
Comments
Post a Comment