Bigcommerce Stencil Custom Handlebars “Replace” Helper

左心房为你撑大大i 提交于 2019-12-11 12:15:11

问题


Is there a syntax example for using the "replace" handlebars helper? The doc is rather vague on the practical usage. Link to doc: here

For instance:

If I had a page name of "About Us" and I wanted to replace the space with a "-".

I have tried {{replace name " " "-"}} to no avail.


回答1:


We've revised the documentation on for handlebars.js helpers to include this example:

The following code would search for the string needle within the scope defined by haystack; if found, it would replace that string with the Handlebars block defined by :

{{#replace "needle" haystack}}
  {{<context to use as a replacement>}}
{{/replace}}


来源:https://stackoverflow.com/questions/37487158/bigcommerce-stencil-custom-handlebars-replace-helper

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!