templates - Meteor动态创建新模板
当应用程序运行时,是否可以创建新模板(来自var或集合)?
类似的东西:
MyHtmlTmpl from var or collection > Create new Template.MyNewTmpl > Insert in dom
感谢
最佳答案:
1 个答案:
答案 0 :(得分:0)
编辑你需要
meteor add spacebars-compiler
然后你可以这样写:
function renderTemplateWithData (content, data, parent) {
var newView = Blaze.With(
data,
eval(SpacebarsCompiler.compile(content, { isBody: true }))
)
Blaze.render(newView, parent)
}
可以这样使用:
renderTemplateWithData('<h1>{{title}}</h1>', { title : "hello world" }, document.body)
本文经用户投稿或网站收集转载,如有侵权请联系本站。