将数据传递到动态模板 [英] Pass data to a dynamic template
本文介绍了将数据传递到动态模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
随着流星更新达到0.8,我的旧代码停止工作.
With meteor updates up to 0.8 my old code stopped working.
Handlebars.registerHelper('getTemplate', function(id, context) {
return Template[id](context);
});
<template name="main">
....
{{{getTemplate templateName context}}}
....
</template>
//somewhere in other template
Template.main.context = {name:value};
这样,我可以使用自定义数据呈现自定义模板.现在,我找不到将context
传递给动态模板的方法.出现火焰时,templateName
和context
均未定义.有什么建议吗?
This way I was able to render a custom template with custom data. Now I can't find the way to pass context
to the dynamic template. With blaze both templateName
and context
is undefined. Any advice?
推荐答案
流星> = 0.8.2
您可以使用UI.dynamic
帮助器来渲染具有动态指定的上下文的模板.有关更多详细信息,请查看此问题.
Meteor >= 0.8.2
You can use the UI.dynamic
helper render a template with a context which are both specified dynamically. For more details, check out this issue.
这两个问题都在流星Wiki中的此页面中得到解决.
Both of these issues are addressed on this page in the meteor wiki.
-
Handlebars.registerHelper
现在是UI.registerHelper
,如这里.
查看全文