Logic-less templates.
GitHub: http://mustache.github.com/
Document: Http://mustache.github.com/mustache.5.html
Http://mustache.github.io
Java version Mustache SVN source
Http://jmustache.googlecode.com/svn
Mustache SimilarFreemark and valicity template engines, but mustache is more lightweight and supports languages: Ruby, Javascript, Python,Erlang, node. js, Php, Perl, Perl6, Objective-c, Java, C#/.net, Android, C++, Go, Lua,Ooc, ActionScript, ColdFusion, Scala, Clojure,Fantom, Coffeescript, D, Haskell, Xquery,Asp, Io, Dart, Haxe, Delphi, Racket, Rust,OCaml, Swift, and forBash
Mustache support is weak, but we can build on the mustache to extend the implementation.
mustache is characterized by very simple syntax, the main syntax is as follows
- {{name}} print variable, default is escape, if not escape, with 3 delimiter {{{name}}}, or {{&name}}, this is not related to delimiter
- {{#person}} ... {{/person}} chunks, 4 ways
- Person is a true or false value, determines whether the output
- The person is a list of array that loops through for x in Person:section.render (' xxx)
- The person is an anonymous function/object, and the chunk-wrapped HTML is passed in as a parameter
- Person is dict, direct print Dict[key]
- {{^person}} ... {{/person}, reverse chunk
- {{! Name}} Comment
- {{> box}} loading Submodule
Template:
{{#person?}} Hi {{name}}!{{/person?}}
Hash:
{ "person?": { "name": "Jon" }}
Output:
Hi Jon!
Template:
{{#repo}} <b>{{name}}</b>{{/repo}}{{^repo}} No repos :({{/repo}}
Hash:
{ "repo": []}
Output:
No repos :(
Mustache Template engine