我有这个 html x 车把代码:
{{#each product.custom_fields}}
{{#if name '===' 'hero_image_name'}}
<source media="(min-width: 800px)"
srcset="{{cdn "webdav:product_images/{{{value}}}"}}"
{{/if}}
{{/each}}>
问题是,我无法在 srcset 中呈现“{{{value}}}”。它只是从字面上输出“{{{value}}}”。
我试着用反斜杠转义它,像这样的脚本:
Handlebars.registerHelper('escape', function(variable) {
return variable.replace(/(['"])/g, '\\$1');
});
然后添加:
{{{escape value}}}
但似乎没有任何效果。我找不到像这样的任何具体案例,有人知道如何输出这个吗?