Friday 15 July 2011

javascript - How do I make {{#each}} work with these templates? -



javascript - How do I make {{#each}} work with these templates? -

i have been reading these tutorials on spacebars.

understanding spacebars david burles

meteor's spacebars readme on github

discover meteor's spacebars secrets

i think can understand pretty good, having problem

i have main.html template this

<template name="main"> <div class="container"> <section id="bl-work-section"> <div class="bl-box"> <h4 class="sin">próximo</h4> <h2 id="titulo1" class="sin"></h2> <h4 class="sin" id="sub1"></h4> </div> <div class="bl-content"> <h2>lunes 25 de noviembre del 2014</h2> {{#each mostrarlunes}} {{> lunes}} {{/each}} <a></a> </div> <span class="bl-icon bl-icon-close"></span> </section> <!-- panel items works --> <div class="bl-panel-items" id="bl-panel-work-items"> {{#each mostrarlunes}} {{showpromos}} {{/each}} </div> </div> </div><!-- /container --> </template>

so guys see im calling 2 templates within main template , 2 templates this

lunes.html template

<template name="lunes"> <ul id="bl-work-items"> <li data-panel="panel"> <div class="oferta"> <a href="#"> <h3>promocion: {{metadata.nombrepromo}} </h3><br><small>descripcion:{{metadata.descripcionpromo}}</small></a> </div></li><br><br> </ul> </template>

showpromos.html template

<template name="showpromos"> <div data-panel="panel"> <div> <h1>estoy viendo esto en la segunda pagina </h1> <h3>nombre promo {{metadata.nombrepromo}}</h3> <p>descripcion promo.{{metadata.descripcionpromo}}</p> </div> </div> <nav> <span class="bl-icon bl-icon-close"></span> </nav> </template>

so problem? if @ template lunes , showpromos, have data-panel="panel", seems info panel don't work when wrap value on {{each}} tags, because if use, {{each}} tags outside data-panel selector works, seems not working seems don't have connection.

so im asking if there way connect value? seek helper attributes 3rd link says, , don't work, attributes helpers this

template.main.helpers({ attributes: function () { homecoming { datapanel: "prueba", } } });

helper mostrarlunes

template.main.helpers({ 'mostrarlunes' : function(){ homecoming promociones.find({'metadata.diaoferta' : { $in: ['lunes'] } }); } });

looks info context isn't set. seek creating template helper other templates info (i don't understand spanish i'm assuming mongodb cursor need...

templates.lunes.helpers({ data: function() { homecoming promociones.find({'metadata.diaoferta' : { $in: ['lunes'] } }); } }); templates.showpromos.helpers({ data: function() { homecoming promociones.find({'metadata.diaoferta' : { $in: ['lunes'] } }); } });

javascript css3 templates meteor spacebars

No comments:

Post a Comment