Check, if subcomponent exists inside template

In the documentation I found following example:

Doc: Spacebars templates | BlazeJS

I would like to ask, if is possible to modify the #if condition by following way:

{{#if myTemplate}} <-- how to check, if template exists - how to make this condition?
<div class="myTemplateWrapper">
    {{> myTemplate}}
</div>
{{/if}}

or…

{{#if Template.dynamic template='myTemplate'}} <-- how to check, if template exists - how to make this condition?
<div class="myTemplateWrapper">
    {{> Template.dynamic template='myTemplate'}}
</div>
{{/if}}

Thank you very much for each help :slight_smile:

You could add a check helper

Template.example.helpers({
  checkTemplateExists(name) {
    return Template[name] !== undefined;
  }
});
{{#if checkTemplateExists 'myTemplate'}}
  <div class="myTemplateWrapper">
    {{> Template.dynamic template='myTemplate'}}
  </div>
{{/else}}
  <p class="error">Could not find template</p>
{{/if}}

Or add the helper globally with Template.registerHelper