将Blaze模板作为参数传递给函数会创建Famous.js曲面

时间:2015-06-21 15:52:15

标签: meteor famo.us meteor-blaze

我正在尝试更新我的famous.js曲面' content使用Meteor Blaze.toHTMLWithData(template, data)Blaze.toHTMLWithData(Template.roomIlanSpecsTemplate, data)surface,在功能中创建着名view的着名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); 函数,然后使用该函数定义和function createIlanView(data, template){ var ilanSpecsSurface = new Surface({ content: Blaze.toHTMLWithData(template, data), properties: { fontSize: "14px" } }); return ilanSpecsSurface; } 功能,则可以正常工作。

我想念的是什么?

app.use

createFn definiton的一部分:

Router

1 个答案:

答案 0 :(得分:0)

如果全部是关于旧的,那么使用来自https://stackoverflow.com/a/30445791/2288496

的反应曲面会怎么样
var ReactiveTemplate = famodev.ReactiveTemplate;


var reactive = new ReactiveTemplate({
   template: Template.mytemplate,
   data: Collection.find().fetch(),
   properties: {}
});

如何实现路由,订阅等的一个很好的例子https://github.com/sayawan/flowwy

相关问题