gpt4 book ai didi

javascript - mustache 在服务器(rails)和客户端(javascript)上呈现

转载 作者:搜寻专家 更新时间:2023-11-01 05:16:12 24 4
gpt4 key购买 nike

在服务器(使用 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!") %>

以上内容不可扩展。我不想为此制作自己的引擎。

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

此外,还有一个负责服务器和客户端上的嵌套模板?

最佳答案

Poirot可用:Mustache + Rails 3。

关于javascript - mustache 在服务器(rails)和客户端(javascript)上呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7045656/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com