Reputation: 3040
Currently I can get custom fields all or none. Like this
{{#each product.custom_fields}}
{{ id }} : {{ name }} : {{ value }}
{{/each}}
but what if i want to call just one of them by id or name like the below. Is there a way to do that with stencil or otherwise?
{{product.custom_fields.id:4.name}}
Upvotes: 2
Views: 562
Reputation: 1866
You can use the existing {{if}} helper to accomplish this
{{#if display_name '===' 'material'}}
{{#each product.custom_fields}}
{{id}} : {{name}} : {{value}}
{{/each}
{{/if}}
Upvotes: 1
Reputation: 83981
You can select a list item by id. {{product.custom_fields.id.4.name}}
, however, if you want to select by name you'll need to implement a conditional as @alyss suggested.
See: How do I access an access array item by index in handlebars?
Upvotes: 1