我正在尝试使用 EJS gem 在 rails 3.1 中进行模板化。当我在 application.js 文件中需要我的模板时
//= 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 的体验。我需要手动执行吗?我错过了什么吗?
提前致谢,
一个