Rails 混合模板语言
我正在处理一个大型项目,其中模板是用 erb 编写的。我们越来越多地进行项目部分的客户端渲染,并且我们的 erb 模板的 Mustache 中有很多精确的重复项。
我想将在 Mustache 中复制的 erb 模板更改为 Mustache 并从这些模板中打印出 js 模板。
我一直无法弄清楚如何在 Rails 中混合模板语言,这可能吗?我不想重写 Mustache 中的所有 erb 模板。
谢谢!
I'm working with a large project where the templates are written in erb. We're getting more and more into client side rendering of parts of the project and we have lots of exact duplicates in mustache of our erb templates.
I'd like to change the erb templates that are replicated in mustache to mustache and print the js templates out from those templates.
I haven't been able to figure out how to mix templating languages in rails though, is this possible? I'd rather not rewrite all the erb templates in mustache.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许同位素 对你有用吗?但我从未尝试过。
Maybe Isotope could be useful for you? I never tried it though.
我担心你没有直接的解决方案...
另一种选择:
如果你插入车把模板,你可以重用由 ruby 创建的旧 html。但这是另一个js库...
http://www.handlebarsjs.com/
I fear you'd have no direct solution...
An alternative:
You could reuse your good old html created by ruby if you insert in handlebars templates. But it's another js library...
http://www.handlebarsjs.com/