简体   繁体   English

动态创建模板-流星

[英]Create Template Dynamically - Meteor

I want to create new template whenever a button is clicked 我想在单击按钮时创建新模板

 <input text="button" class="btn" value="click to create template" />


 -->js part

 'click input.btn' : function(){
           //create template here
 }

can someone help me on how to do this ? 有人可以帮助我吗? thanks ! 谢谢 !

I don't believe there is any easy way to do this.. Meteor compiles all your templates during the build process and there is some pretty intense manipulation going on behind the scenes. 我不相信有任何简单的方法可以做到这一点。Meteor在构建过程中会编译所有模板,并且在幕后进行了一些非常激烈的操作。 A simple template is pretty easy to create like this. 像这样创建一个简单的模板非常容易。

Meteor._def_template("Hello",Handlebars.json_ast_to_func(["<div>Hello World!</div>"]));

Once you start adding the handlebars variables and block helpers it seems to get pretty complicated. 一旦开始添加handlebars变量并阻止辅助程序,它似乎会变得非常复杂。

If you want to research it more you can dive into the .meteor directory of your project and explore. 如果您想进行更多研究,可以进入项目的.meteor目录并进行探索。 Templates should be located somewhere under ./meteor/local/build/static_cacheable depending on how you set up your folder structure for your project. 模板应位于./meteor/local/build/static_cacheable下的某个位置,具体取决于您为项目设置文件夹结构的方式。 Each template file is in the form template. 每个模板文件都在表单模板中。 templateName .js templateName .js

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM