1MUSTACHE(1)                     Mustache Manual                    MUSTACHE(1)
2
3
4

NAME

6       mustache - Mustache processor
7

SYNOPSIS

9       mustache <YAML> <FILE>
10       mustache --compile <FILE>
11       mustache --tokens <FILE>
12

DESCRIPTION

14       Mustache is a logic-less templating system for HTML, config files, any‐
15       thing.
16
17       The mustache command processes a Mustache  template  preceded  by  YAML
18       frontmatter  from  standard  input  and prints one or more documents to
19       standard output.
20
21       YAML frontmatter begins with --- on a single line,  followed  by  YAML,
22       ending with another --- on a single line, e.g.
23
24
25
26           ---
27           names: [ {name: chris}, {name: mark}, {name: scott} ]
28           ---
29
30
31
32       If  you  are unfamiliar with YAML, it is a superset of JSON. Valid JSON
33       should work fine.
34
35       After the frontmatter should come any valid Mustache template. See mus‐
36       tache(5) for an overview of Mustache templates.
37
38       For example:
39
40
41
42           {{#names}}
43             Hi {{name}}!
44           {{/names}}
45
46
47
48       Now let´s combine them.
49
50
51
52           $ cat data.yml
53           ---
54           names: [ {name: chris}, {name: mark}, {name: scott} ]
55           ---
56
57           $ cat template.mustache
58           {{#names}}
59             Hi {{name}}!
60           {{/names}}
61
62           $ mustache data.yml template.mustache
63           Hi chris!
64           Hi mark!
65           Hi scott!
66
67
68
69       If you provide multiple YAML documents (as delimited by ---), your tem‐
70       plate will be rendered multiple times. Like a mail merge.
71
72       For example:
73
74
75
76           $ cat data.yml
77           ---
78           name: chris
79           ---
80           name: mark
81           ---
82           name: scott
83           ---
84
85           $ cat template.mustache
86           Hi {{name}}!
87
88           $ mustache data.yml template.mustache
89           Hi chris!
90           Hi mark!
91           Hi scott!
92
93
94

OPTIONS

96       By default mustache will try to render a Mustache  template  using  the
97       YAML frontmatter you provide. It can do a few other things, however.
98
99       -c, --compile
100              Print the compiled Ruby version of a given template. This is the
101              code that is actually used when  rendering  a  template  into  a
102              string.  Useful  for debugging but only if you are familiar with
103              Mustache´s internals.
104
105       -t, --tokens
106              Print the tokenized form of a given Mustache template. This  can
107              be used to understand how Mustache parses a template. The tokens
108              are handed to a  generator  which  compiles  them  into  a  Ruby
109              string. Syntax errors and confused tags, therefore, can probably
110              be identified by examining the tokens produced.
111

INSTALLATION

113       If you have RubyGems installed:
114
115
116
117           gem install mustache
118
119
120

EXAMPLES

122       $ mustache data.yml template.mustache
123       $ cat data.yml | mustache - template.mustache
124       $ mustache -c template.mustache
125       $ cat <<data | ruby mustache - template.mustache
126       ---
127       name: Bob
128       age: 30
129       ---
130       data
131
133       Mustache is Copyright (C) 2009 Chris Wanstrath
134
135       Original CTemplate by Google
136

SEE ALSO

138       mustache(5), gem(1), http://mustache.github.io/
139
140
141
142DEFUNKT                          November 2016                     MUSTACHE(1)
Impressum