简体   繁体   中英

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. 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.

If you want to research it more you can dive into the .meteor directory of your project and explore. Templates should be located somewhere under ./meteor/local/build/static_cacheable depending on how you set up your folder structure for your project. Each template file is in the form template. templateName .js

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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