小胡子在服务器(rails)和客户端(javascript)上呈现

Mar*_*son 4 javascript ruby-on-rails mustache

在服务器(使用rails)和客户端(使用javascript)上使用时,是否有关于Mustache最佳实践的文档?

# hello_world.mustache
Hello {{planet}}

# some other file
<%
hello_world_template = File.read(File.dirname(__FILE__) + "/hello_world.mustache")
%>

<script id="hello_world_template" type="text/x-jquery-tmpl"> 
    <%= hello_world_template %>
</script>

<script>
    // $.mustache = using mustache.js and a jquery mustache wrapper 
    // search on "Shameless port of a shameless port"
    document.write($.mustache($("#hello_world_template").html(), { "planet" : "World!" }));
</script>

<%= Mustache.render(hello_world_template, :planet => "World!") %>
Run Code Online (Sandbox Code Playgroud)

以上是不可扩展的.我不想为此制作自己的发动机.

是否有更完整的模板引擎允许在服务器和客户端上重用模板?

另外,还有一个可以解释服务器和客户端上的嵌套模板吗?

apn*_*ing 5

Poirot可用:Moustache + Rails 3.

  • 我会检查一下,谢谢.我也见过一种叫做Isotope的东西.现在阅读.http://devign.me/isotope-hybrid-ruby-on-rails-template-engine-for-client-side-and-server-side/ (2认同)