简体   繁体   中英

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

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?

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 – embedded javascript
  • .jst – javascript template

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM