Closed
Description
I'm trying to treat partials as "components" that only have access to variables that were passed in as attributes — is this possible?
my-partial.hbs
<div class="my-partial">
<!-- should only be displayed if it was passed in as an attribute -->
{{#if name}}
Hello, {{name}}
{{/if}}
</div>
my-app.js
const data = { name: 'Adam' }
my-app.hbs
Hello, my name is {{name}} and is available in the template scope
{{> myPartial}}
{{> myPartial name="John"}}
Actual output
Hello, my name is Adam and is available in the template scope
<div class="my-partial>
Hello, Adam
</div>
<div class="my-partial>
Hello, John
</div>
Desired output
Hello, my name is Adam and is available in the template scope
<div class="my-partial"></div>
<div class="my-partial">
Hello, John
</div>
Metadata
Metadata
Assignees
Labels
No labels