template(name='main')
each posts
.thumbContainer(class="#{addFrame}")
img(src="#{img.dataURL}"
.corner(class="#{addCorner}")
.ribbon(class="#{addRibbon}")
And I would like to have the following helper logic(coffee):
Template.main.helpers
posts: -> Posts.find({})
addFrame: -> if posts.options.addFrame then return 'hasFrame'
addCorner: -> if posts.options.addCorner then return '.visible'
addRibbon: -> if posts.options.addRibbon then return '.visible'
Create a Template Helper that will return a class name
Template.registerHelper('showFrame', function(frame) {
if ( frame)
return framer // framer will be you class name
});
{{#each posts}}
<div class = {{ showFrame 'options.addFrame' }} >
show something here
</div>
{{/each}}
another solution without a Template Helper is below but I haven’t tried it though
{{#each posts}}
{{#if options.addFrame}}
<div class ="framer" >
show something here
</div>
{{else}}
<div>
show something here too
</div>
{{/if}}
{{/each}}