我有这个模板:
I have this template:
<template name="sample"> <h1>Sample</h1> </template>在Meteor应用程序中,我可以用这种方式将它添加到body中(作为partial):
Inside a Meteor app I can add this to body this way (as a partial):
{{> sample}}它的工作原理。我甚至测试过要调用Template.sample();在浏览器控制台中,它可以正常工作。
It works. I've even tested to call Template.sample(); inside browser console and it works.
当我将其移动到我的包中时(即包文件夹中的sample.html文件),模板似乎消失了: code> Template.sample()不是一个函数,只要我调用函数,我甚至不能把它作为一个局部变量来呈现。
When I move this inside my package (i.e. a sample.html file inside my package folder) the template seems to disappear: I get Template.sample() is not a function whenever I call the function and I am not even able to render it as a partial.
我有这个代码的 package.js (显然这个包通过 packages正确地加载到我的应用程序中$ c $ .meteor ):
I have a package.js with this code (and obviously the package is correctly loaded inside my app through packages file in .meteor):
Package.on_use(function (api) { api.add_files(['sample.html', 'sample.js'], 'client'); });为什么这不起作用? 如何从我的包裹中追加(反应性)模板到正文?
Why this doesn't work? How can I append a (reactive) Template to body from my package?
推荐答案解决了!添加以下行:
Solved! Add this line:
api.use(['templating'], 'client');更多推荐
如何在包中的Meteor中将模板添加到body中
发布评论