作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以我已经阅读了关于 Handlebars partials 的官方文档.
它指出:
In order to use a partial, it must be registered via
Handlebars.registerPartial
.
Handlebars.registerPartial('myPartial', '{{name}}')
This call will register the myPartial partial. Partials may be precompiled and the precompiled template passed into the second parameter.
{{name}}
应该是当你没有预编译任何东西的时候。我不想注册内联模板,我将它们作为单独的文件放在
templates/partials
中,例如
templates/partials/_header.hbs
.我只需要使用
gulp-handlebars
生成 HTML 作为构建过程的一部分.
最佳答案
您引用的文档中的部分说:
Partials may be precompiled and the precompiled template passed into the second parameter.
'{{name}}'
带有预编译的部分。这将要求您使用
-p
预编译部分。旗帜。
-p
的情况下将模板和部分预编译在一起。旗帜。 (基本上将部分预编译为模板)。通过这样做,您不需要预先注册部分。
Handlebars.partials = Handlebars.templates;
在您的代码处理任何模板或部分之前。
关于handlebars.js - Handlebars 部分文件不清楚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48867218/
MVC3 中的助手是否在 Controller 和 View 中使用? 助手是放置常用 Controller 方法的正确位置吗? 我想创建一个通用方法来获取数据库中的所有子子 ID,并确保它位于正确的
有人可以阐明这两者之间的区别吗,因为它们存在于执行上下文中?我很难阅读 ECMA 262 v 5规范并清楚地看到差异。 谢谢你, 最佳答案 两者都是执行上下文的组件(相同类型),但它们有不同的用途(f
我是一名优秀的程序员,十分优秀!