我想在rails 3.1中使用EJS gem模板。当我要求我在的application.js模板文件在rails 3.1中的EJS gem不会正确编译JavaScript模板
//= require_directory ./templates
我得到在客户端的输出包装在一个匿名函数和命名空间它的模板,但......就是这样。这是我得到的生成输出。
(function() {
this.JST || (this.JST = {});
this.JST["templates/index"] = <article class="item <%=type%>">
<% if (type === "stat") { %>
<h2>
<span>70%</span>
of teens have one or more social network profiles
</h2>
<% } else { %>
<header>
<a href="/posts/<%=id%>">
<h3><%=type%></h3>
<h2><span>- <%=type%></span></h2>
</a>
</header>
<% if (confidential) { %>
<span class="confidential">Confidential</span>
<% } %>
<% if (type === "video" || type === "music") { %>
<a href="/posts/<%=id%>" class="play">play</a>
<% } %>
<a href="/posts/<%=id%>"><img src="<%=image%>" alt="" /></a>
<% } %>
</article>;
}).call(this);
我希望模板编译成一个字符串。这是我和Jammit过去的经历。我需要手动执行此操作吗?我错过了什么吗?
由于提前,
一个