Mustache Template engine

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.