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

…衆ロ難τιáo~ 提交于 2019-12-11 21:07:23

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/24729649/what-core-meteor-methods-can-i-call-to-compile-a-new-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!