Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
279 views
in Technique[技术] by (71.8m points)

javascript - What core Meteor methods can I call to compile a new template?

I'm specifically trying to do this client side but it it can only be done server side I will use Meteor.call to return the compiled template as a string via DDP/Ajax.

My end goal is to dynamically create new templates (HTML, events, helpers, etc) at runtime. And then sometimes replace existing templates with updated ones.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The compilation of templates is done on the server, see

https://github.com/meteor/meteor/tree/devel/packages/spacebars-compiler

I don't think you'd want to do this on the client because then each client may have different local templates and display things differently. You would have to send the templates to the server anyway so that other clients could get them updated as well. Same thing for helpers, etc.

Are you sure that you can't achieve this by defining some templates that can be shared across clients and then updating the data context? It seems you are trying to create some way for clients to produce new templates for the app, but you can accomplish this by having some sort of structured data that nests existing templates together to create custom views.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...