小胡子在服务器(rails)和客户端(javascript)上呈现 [英] Mustache render on the server (rails) and on the client (javascript)

查看:78
本文介绍了小胡子在服务器(rails)和客户端(javascript)上呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Is there any documentation on Mustache best practices when using on the server (with rails) and on the client (with javascript)?

# 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!") %>

以上内容不具备可扩展性。我不想为此制作自己的发动机。

The above isn't scalable. I'd prefer not to make my own engine for this.

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

Is there a more complete templating engine that allows reuse of templates on the server and on the client?

另外,在服务器和客户端上占用嵌套模板的那个?

Additionally, one that accounts for nested templates on the server and the client?

推荐答案

Poirot :Moustache + Rails 3。

There is Poirot available: Mustache + Rails 3.

这篇关于小胡子在服务器(rails)和客户端(javascript)上呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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