I am trying to make a contextual component that can provide a default header when one is not passed in the yielded block. Normally, I could use the has-block helper to tell if a component has block content but this component will always have block content. I think what I need is a way to tell if the yielded component has block content. For example:
{{! panel.hbs }}
<header>
{{yield header=(component "blank-template")}}
{{#if (yieldedHeaderEmpty)}}
<h1>My Default Header</h1>
{{/if}}
</header>
<section>
{{yield body=(component "blank-template")}}
</section>
<footer>
{{yield footer=(component "blank-template")}}
</footer>
I only want the default header to show when the yielded "header" section is empty. I could create a header component which then could use the has-block like so:
{{! panel.hbs }}
<header>
{{yield header=(component "my-header")}}
</header>
...
{{! MyHeader.hbs}}
{{#if (has-block)}}
{{yield}}
{{else}}
<h1>My Default</h1>
{{/if}}
Functionally I think this will work but the only purpose of the "my-header" component would be for this "panel" component and seems wasteful. Open to ideas. Thanks!