mustache.js 是一个 Mustache 模板系统的 JavaScript 实现。
Mustache 模板语法的逻辑比较简单。它用于HTML,配置文件,源代码等。它的工作方式是通过通过以哈希值或者对象的方式扩展模板标签。
下面是一个简单的如何用 mustache.js的例子:[code]var view = {
title: "Joe",
calc: function () {
return 2 + 4;
}
};
var output = Mustache.render("{{title}} spends {{calc}}", view);[/code]在这个例子中, the Mustache.render 函数有2个参数: 1) mustache 模板和 2)包含了需要渲染给模板的数据和代码的一个视图对象。
主页:https://github.com/janl/mustache.js/
下载:https://github.com/janl/mustache.js/downloads
来自:开源中国社区

