Javascript rails-backbone gem 中 EJS 和 JST 模板文件的格式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6557238/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Format of EJS and JST template files in rails-backbone gem
提问by Nik So
I am using the rails-backbone gem ( https://github.com/codebrew/backbone-rails). For rendering HTML, it uses some kind of javascript templates, whose name I cannot tell even after a few hours of search.
我正在使用 rails-backbone gem ( https://github.com/codebrew/backbone-rails)。为了呈现 HTML,它使用了某种 javascript 模板,即使经过几个小时的搜索,我也无法说出其名称。
For example, it generates such a file for the view template:
例如,它为视图模板生成这样一个文件:
# company.jst.ejs
<td><%= name %></td>
<td><%= tid %></td>
<td><a href="#/<%= _id %>">Show</td>
<td><a href="#/<%= _id %>/edit">Edit</td>
<td><a href="#/<%= _id %>/destroy" class="destroy">Destroy</a></td>
My questions are: what is .jst format? And in Rails 3.1, what library processes it? Same question for the .ejs extension. And what's the name of this template engine? Underscore?
我的问题是:什么是 .jst 格式?而在 Rails 3.1 中,哪个库处理它?.ejs 扩展名的相同问题。这个模板引擎的名字是什么?下划线?
回答by Heikki
Rails processes EJS templates with ejs gemwhich is a port of underscore.js's _.templatefunction to Ruby. Output of that is a javascript function which in turn will produce the html when run in the browser.
Rails 使用ejs gem处理 EJS 模板,ejs gem是 underscore.js 的_.template函数到 Ruby的端口。它的输出是一个 javascript 函数,它反过来会在浏览器中运行时生成 html。
- .ejs – embedded javascript
- .jst – javascript template
- .ejs – 嵌入式 JavaScript
- .jst – javascript 模板
Here's recent article which includes also description of backbone-rails:
这是最近的文章,其中还包括对骨干导轨的描述:
回答by techvineet
A very good reference to what all this is about is here:-
关于这一切的一个很好的参考是在这里:-
http://www.bigjason.com/blog/precompiled-javascript-templates-rails-3-1
http://www.bigjason.com/blog/precompiled-javascript-templates-rails-3-1