I want to create a blaze template which can be used to wrap other stuff by using Template.contentBlock. But I want it to have a default value if it isn’t used as a wrapper:
The wrapper-template would look like: {{#if Template.contentBlock}} {{> Template.contentBlock}} {{else}} <div>default</div> {{/if}}
But the if-clause don’t work like this, as it is always true – so is there a simple way to achieve this?
Okay, I think I found it:
Within the helper I can call: Template.instance().view.templateContentBlock
So I created a global helper: Template.registerHelper('hasChild', function () { return (Template.instance().view.templateContentBlock) ? true : false; });
No I can use it like: {{#if hasChild}} {{> Template.contentBlock}} {{else}} <div>default</div> {{/if}}