handelbars变量通过车把。

发布于 2025-01-27 19:40:12 字数 338 浏览 1 评论 0原文

我有一个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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

日暮斜阳 2025-02-03 19:40:12

根据 handlebars文档作为一个参数,像这样:

{{> data parameter=variable }}

As per the handlebars documentation, you should be able to simply pass the variable down as a parameter, like so:

{{> data parameter=variable }}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文