Format of EJS and JST template files in rails-backbone gem

匿名 (未验证) 提交于 2019-12-03 02:45:02

问题:

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> 

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?

回答1:

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.

Here's recent article which includes also description of backbone-rails:



回答2:

A very good reference to what all this is about is here:-

http://www.bigjason.com/blog/precompiled-javascript-templates-rails-3-1



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