Meteor 将Blaze模板作为参数传递给函数将创建著名的.js曲面
我正在尝试使用Meteor的Meteor 将Blaze模板作为参数传递给函数将创建著名的.js曲面,meteor,famo.us,meteor-blaze,Meteor,Famo.us,Meteor Blaze,我正在尝试使用Meteor的Blaze.toHTMLWithData(模板,数据)更新我著名的.js surfaces的内容,比如Blaze.toHTMLWithData(template.roomIlanSpecsTemplate,数据),在一个函数中使用一个自定义模板在著名的视图中创建一个著名的表面。我想在cursorToArray函数中传递模板,具体取决于返回到其回调的文档类型。但我无法在浏览器上呈现页面,即使控制台中没有错误。如果我使用硬编码版本,比如为每个不同的模板使用createFn
Blaze.toHTMLWithData(模板,数据)
更新我著名的.js surfaces的内容
,比如Blaze.toHTMLWithData(template.roomIlanSpecsTemplate,数据)
,在一个函数中使用一个自定义模板在著名的视图
中创建一个著名的表面
。我想在cursorToArray
函数中传递模板,具体取决于返回到其回调的文档类型。但我无法在浏览器上呈现页面,即使控制台中没有错误。如果我使用硬编码版本,比如为每个不同的模板使用createFn
函数,然后使用该函数定义和cursorToArray
函数,它就会工作
我错过了什么
cursorToArray = function(cursor, renderablesArray, template, createFn){
//each callback should decide which createFn to use based on result document, cos each result has a different template so a createFn.
cursor.observe({
addedAt: function(document, atIndex, before) {
renderablesArray.splice(atIndex, 0, createFn(document, template));//createRoomIlanView, createRoomRenterIlanView, createFriendLookupIlanView
},
changedAt: function(newDocument, oldDocument, atIndex) {
renderablesArray[atIndex] = createFn(newDocument, template);
},
});
}
cursorToArray(Ilans.find(), ilanViews, Template.roomIlanSpecsTemplate, createIlanView);
createFn定义的一部分:
function createIlanView(data, template){
var ilanSpecsSurface = new Surface({
content: Blaze.toHTMLWithData(template, data),
properties: {
fontSize: "14px"
}
});
return ilanSpecsSurface;
}
如果都是关于旧的,那么使用来自
如何实现路由、订阅等的一个很好的示例。您在哪里将新的
曲面
添加到著名引擎
的上下文中?我已相应地编辑了标记。实际创建。。。函数创建famo.us视图
。adn向一些分支添加了修饰符
和曲面
。上面的曲面是这些分支顶端的曲面之一,源于视图
。此视图用于填充数组,它作为我在headerfooterlayout的内容部分中使用的滚动视图的序列。我认为问题在于在内容中传递Blaze
函数调用的参数从表面上看。如果它像我在Q中所说的那样是硬编码的,那么它就可以工作Blaze.toHTMLWithData(Template.roomIlanSpecsTemplate,data)
。但我想把它简单化。
var ReactiveTemplate = famodev.ReactiveTemplate;
var reactive = new ReactiveTemplate({
template: Template.mytemplate,
data: Collection.find().fetch(),
properties: {}
});