I have this html x handlebars code:
{{#each product.custom_fields}}
{{#if name '===' 'hero_image_name'}}
<source media="(min-width: 800px)"
srcset="{{cdn "webdav:product_images/{{{value}}}"}}"
{{/if}}
{{/each}}>
the problem is, I cannot render the "{{{value}}}" inside the srcset. It just literally outputs "{{{value}}}".
I tried escaping it, with backslashes, scripts like these:
Handlebars.registerHelper('escape', function(variable) {
return variable.replace(/(['"])/g, '\\$1');
});
and then adding:
{{{escape value}}}
but nothing seems to work. I couldn't find any specific case like this, does someone has an idea how to output this?
You need to use it like this
{{#each product.custom_fields}}
{{#if name '===' 'hero_image_name'}}
<source media="(min-width: 800px)"
// with double braces not triple {{value}}
srcset="{{cdn "webdav:product_images/{{value}}"}}"
{{/if}}
{{/each}}>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.