的EJS和JST模板文件格式轨骨干宝石 [英] Format of EJS and JST template files in rails-backbone gem

查看:428
本文介绍了的EJS和JST模板文件格式轨骨干宝石的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的轨道骨干宝石( https://github.com/$c $ cbrew /骨干网护栏)。为了呈现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模板与 EJS宝石这是underscore.js的 _.template 功能红宝石的一个端口。那输出从而在浏览器中运行时会产生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模板文件格式轨骨干宝石的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆