When assigning properties to a template instance in the created method of a template and a helper of that template is invoked inside a custom block helper, which is in turn invoked inside the actual template, the template instance of Template.instance() will be that of the custom block helper and not of the "real" template. For example, consider this:
<template name="templateBug">
{{#contentBlockTemplate}}
<span>{{notVisibleString}}</span>
{{/contentBlockTemplate}}
</template>
and notVisibleString is using Template.instance() to access a property of the template instance; then that instance will be that of contentBlock and not templateBug, which to me is counter intuitive and makes it difficult to use a custom block helper with assigning properties to a template instance in Template.myTemplate.created.
Steps to reproduce
Example project which visualizes this here: https://github.com/lbergnehr/meteor_template_content_block_bug
git clone https://github.com/lbergnehr/meteor_template_content_block_bug.git
cd meteor_template_content_block_bug
git checkout with_content_block
meteor
this will not show the intended text, whereas removing the content block will:
git checkout without_content_block
meteor
When assigning properties to a template instance in the
createdmethod of a template and a helper of that template is invoked inside a custom block helper, which is in turn invoked inside the actual template, the template instance ofTemplate.instance()will be that of the custom block helper and not of the "real" template. For example, consider this:and
notVisibleStringis usingTemplate.instance()to access a property of the template instance; then that instance will be that ofcontentBlockand nottemplateBug, which to me is counter intuitive and makes it difficult to use a custom block helper with assigning properties to a template instance inTemplate.myTemplate.created.Steps to reproduce
Example project which visualizes this here: https://github.com/lbergnehr/meteor_template_content_block_bug
this will not show the intended text, whereas removing the content block will: