6. Definition
A template engine is software that is designed to process web
templates and content information to produce output web
documents.
6 Client-side / Overview
10. Definition
Mustache.js is a logic-less template syntax.
It can be used for HTML, config files, source code - anything.
It works by expanding tags in a template using values
provided in a hash or object.
http://mustache.github.com/#demo
10 Client-side / Mustache.js
11. Usage
var view = {
name: "World"
};
var template = "Hello {{name}}";
var output = Mustache.render(template, view);
http://jsfiddle.net/MicheleBertoli/nwNhd/
11 Client-side / Mustache.js
13. Templates
A mustache template is a string that contains any number of
mustache tags.
Tags are indicated by the double mustaches that surround
them.
{{name}}
13 Client-side / Mustache.js
14. Sections
Sections render blocks of text one or more times, depending
on the value of the key in the current context.
http://jsfiddle.net/MicheleBertoli/nwNhd/1
14 Client-side / Mustache.js
15. Functions
If the value of a section key is a function, it is called with the
section's literal block of text, un-rendered, as its first
argument.
http://jsfiddle.net/MicheleBertoli/nwNhd/2
15 Client-side / Mustache.js
16. Inverted sections
The block of an inverted section is rendered only if the value of
that section's tag is null, undefined, false, or an empty list.
http://jsfiddle.net/MicheleBertoli/nwNhd/3
16 Client-side / Mustache.js
17. Comments
Comments begin with a bang and are ignored.
<h1>Today{{! ignore me }} .</h1>
17 Client-side / Mustache.js
19. Compiled templates
Mustache templates can be compiled into JavaScript functions
using Mustache.compile for improved rendering performance.
http://jsfiddle.net/MicheleBertoli/nwNhd/5
19 Client-side / Mustache.js