问题描述
我使用的轨道骨干宝石()。为了呈现HTML,它使用某种JavaScript的模板,他的名字甚至搜查了几个小时后,我也说不清。
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.
例如,它产生这样一个文件的视图模板:
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>
我的问题是:什么是.jst格式?而在Rails的3.1有什么库处理它?对于.ejs扩展同样的问题。而这是什么模板引擎的名字吗?下划线?
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?
推荐答案
Rails的处理EJS模板与这是underscore.js的功能红宝石的一个端口。那输出从而在浏览器中运行时会产生HTML的JavaScript函数。
Rails processes EJS templates with ejs gem which is a port of underscore.js's _.template function to Ruby. Output of that is a javascript function which in turn will produce the html when run in the browser.
- .ejs - 嵌入的JavaScript
- .jst - JavaScript的模板
下面是最近的一篇文章其中还包括:
Here's recent article which includes also description of backbone-rails:
- Where does my javascript code go? Backbone, JST and the Rails 3.1 asset pipeline
这篇关于的EJS和JST模板文件格式轨骨干宝石的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!