如何在模具中获取base_url

时间:2018-06-22 14:26:58

标签: bigcommerce

我无法在模具模板中获取base_url。 {{settings.base_url}}始终返回一个空字符串。 https://stencil.bigcommerce.com/docs/settings-object

是否存在另一个包含站点URL的全局模具对象?

1 个答案:

答案 0 :(得分:0)

(pencil-response.js)中的函数[https://github.com/bigcommerce/stencil-cli/blob/master/server/plugins/renderer/responses/pencil-response.js#L79-L85]  使用正则表达式有意破坏这些值。

regex = new RegExp(internals.escapeRegex(context.settings.base_url), 'g');
content = content.replace(regex, '');

此提交使用的值为request.info.hosthttps://github.com/bigcommerce/stencil-cli/commit/fb9611502613f00a364a8d9ea4e1d3351c834d08

我在此拉取请求中提出了一个解决方案。 https://github.com/bigcommerce/stencil-cli/pull/396