Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
268 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

Just Browsing Browsing

[3] html - How to create even cell spacing within a

2.1m questions

2.1m answers

60 comments

56.8k users

...