handelbars变量通过车把。
我有一个Handelbars应用程序,该应用程序从JavaScript和模板中加载数据。为了使模板上班,我在JavaScript中使用以下内容:
var data = require('partials/data.js');
Handlebars.registerPartial('data', data);
然后在我的部分中,我可以做:
{{> data}}}
我有一个可以在主模板中使用的Handelbars变量,但我想将其传递给部分。与我的其他部分不通过JavaScript注册,这是可能的。我假设我需要像模板一样传递此变量?
I have a Handelbars app that loads data from javascript and partials for the templates. To get the templates to work I use the following in the Javascript:
var data = require('partials/data.js');
Handlebars.registerPartial('data', data);
Then in my partial I am able to do:
{{> data }}
I have a Handelbars variable I can use in my main template but I want to pass it down to the partial. With my other partials that don't register via the Javascript this is possible. I am assuming I need to pass this variable down like I do the templates?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据 handlebars文档作为一个参数,像这样:
As per the handlebars documentation, you should be able to simply pass the variable down as a parameter, like so: