Mustache (template system)
Mustache is a web template system.
≈ 2 min read
Names in other languages
No names in other languages are held for this entry yet.
Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.
Mustache is a web template system. It is described as a logic-less system because it lacks any explicit control flow statements, like if and else conditionals or for loops; however, both looping and conditional evaluation can be achieved using section tags processing lists and anonymous functions (lambdas).
It is named "Mustache" because of heavy use of braces, { } , that resemble a sideways moustache. Mustache is used mainly for mobile and web applications.
Implementations are available in ActionScript, C++, Clojure, CoffeeScript, ColdFusion, Common Lisp, Crystal, D, Dart, Delphi, Elixir, Erlang, Fantom, Go, Haskell, Io, Java, JavaScript, Julia, Lua, .NET, Objective-C, OCaml, Perl, PHP, Pharo, Python, R, Racket, Raku, Ruby, Rust, Scala, Smalltalk, Swift, Tcl, CFEngine, and XQuery. JSON data is fed to Mustache templates, resulting in an output.
Here is some example data: { "name": "World", "greater than": ">" } Hello Mustache HTML escapes data by default. For example, the below would render as 2 > 1 . 2 1 To turn off escaping, use a & .
The below would render as 2 > 1 . 2 1 Some text The special variable refers to the current item when looping through an array, or the item checked in a conditional. A Mustache template can load another inside itself it using the > symbol.
Comments are indicated using an exclamation mark.
Text derived from https://en.wikipedia.org/w/index.php?oldid=1371227500 under CC BY-SA 4.0; modifications have been made.