我正在尝试手工编译一些模板(以电子邮件的形式发送)在服务器端。但是,没有定义Spacebars.compile。当我在控制台上打印Spacebar对象时,我得到以下信息:
{ include: [Function],
mustacheImpl: [Function],
mustache: [Function],
attrMustache: [Function],
dataMustache: [Function],
makeRaw: [Function],
call: [Function],
kw: [Function],
SafeString: [Function],
dot: [Function],
TemplateWith: [Function],
With: [Function] }我做错什么了吗?请注意,我已经尝试过包括空格-编译包手动,但没有显示。
编辑:代码示例
function renderTemplate (template, data) {
var compiled = Spacebars.compile(template, data);
var render = new Function("return " + compiled)();
var tpl = UI.Component.extend({
kind: "dynamicTemplate",
render: render
});
return tpl;
};我知道#.compile是未定义的
发布于 2015-07-20 14:58:31
这个答案对于Meteor版本1.1.0.2是有效的。
首先,您需要添加空格键.编译器包
meteor add spacebars-compiler然后将调用更改为使用SpacebarsCompiler.compile()。
https://stackoverflow.com/questions/25457476
复制相似问题