我可以调用哪些核心 Meteor 方法来编译新模板? [英] What core Meteor methods can I call to compile a new template?

查看:59
本文介绍了我可以调用哪些核心 Meteor 方法来编译新模板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我特别想在客户端做这个,但它只能在服务器端完成我将使用 Meteor.call 通过 DDP/Ajax 将编译后的模板作为字符串返回.

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.

我的最终目标是在运行时动态创建新模板(HTML、事件、帮助程序等).然后有时会用更新的模板替换现有模板.

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

推荐答案

模板的编译是在服务器上完成的,见

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.

这篇关于我可以调用哪些核心 Meteor 方法来编译新模板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆