Reputation: 1684
I have a partial that contains the common structure of my web page:
<script id="page-template" type="text/x-handlebars-template">
.....
<div class="page-content">
<div class="page-header">
<h1>{{title}}
<small>
<i class="ace-icon fa fa-angle-double-right"></i> {{subtitle}}
</small>
{{/if}}
</h1>
</div>
......
</div>
</script>
Then, from each page, I call the partial passing the attributes title and subtitle. It works fine with constants attributes, for instance:
{{#> page title="Customers" subtitle="List of customers"}}
<!-- Page HTML -->
{{/page}}
However, it doesn't work when I try to pass a variable:
{{#> page title="Customer" subtitle="{{customer.name"}}
<!-- Page HTML -->
{{/page}}
It displays {{customer.name}} instead of the real name of the customer. Is it possible to make this work?
Thanks in advance!
Upvotes: 4
Views: 5215
Reputation: 1684
I finally managed to make this work. I let the response here just in case it could benefit someone else:
{{#> page title="Customer" subtitle=customer.name
<!-- Page HTML -->
{{/page}}
It was only needed to remove {{}} and "". Notice that customer is the name of a variable available in the template.
Upvotes: 6