angry_mob_common_targets 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +21 -0
- data/README.md +38 -0
- data/lib/common_mob.rb +9 -0
- data/lib/common_mob/digest.rb +43 -0
- data/lib/common_mob/erb.rb +72 -0
- data/lib/common_mob/file.rb +55 -0
- data/lib/common_mob/patch.rb +51 -0
- data/lib/common_mob/resource_locator.rb +9 -0
- data/lib/common_mob/shell.rb +323 -0
- data/lib/common_mob/template.rb +23 -0
- data/lib/common_mob/version.rb +3 -0
- data/targets/crontab_patch.rb +37 -0
- data/targets/extract.rb +40 -0
- data/targets/fetch.rb +40 -0
- data/targets/files.rb +244 -0
- data/targets/git.rb +84 -0
- data/targets/group.rb +33 -0
- data/targets/packages.rb +94 -0
- data/targets/ruby.rb +13 -0
- data/targets/services.rb +184 -0
- data/targets/shell.rb +43 -0
- data/targets/user.rb +108 -0
- data/vendor/mustache/CONTRIBUTORS +9 -0
- data/vendor/mustache/HISTORY.md +135 -0
- data/vendor/mustache/LICENSE +20 -0
- data/vendor/mustache/README.md +405 -0
- data/vendor/mustache/Rakefile +103 -0
- data/vendor/mustache/benchmarks/complex.erb +15 -0
- data/vendor/mustache/benchmarks/complex.haml +12 -0
- data/vendor/mustache/benchmarks/helper.rb +20 -0
- data/vendor/mustache/benchmarks/simple.erb +5 -0
- data/vendor/mustache/benchmarks/speed.rb +78 -0
- data/vendor/mustache/bin/mustache +90 -0
- data/vendor/mustache/contrib/mustache-mode.el +278 -0
- data/vendor/mustache/contrib/mustache.vim +69 -0
- data/vendor/mustache/examples/hash.rb +16 -0
- data/vendor/mustache/examples/hash.yml +5 -0
- data/vendor/mustache/examples/projects.mustache +26 -0
- data/vendor/mustache/examples/projects.yml +28 -0
- data/vendor/mustache/examples/self.mustache +4 -0
- data/vendor/mustache/examples/self.yml +3 -0
- data/vendor/mustache/examples/simple.mustache +10 -0
- data/vendor/mustache/examples/simple.rb +24 -0
- data/vendor/mustache/lib/mustache.rb +358 -0
- data/vendor/mustache/lib/mustache/context.rb +108 -0
- data/vendor/mustache/lib/mustache/generator.rb +160 -0
- data/vendor/mustache/lib/mustache/parser.rb +230 -0
- data/vendor/mustache/lib/mustache/sinatra.rb +180 -0
- data/vendor/mustache/lib/mustache/template.rb +59 -0
- data/vendor/mustache/lib/mustache/version.rb +3 -0
- data/vendor/mustache/lib/rack/bug/panels/mustache_panel.rb +81 -0
- data/vendor/mustache/lib/rack/bug/panels/mustache_panel/mustache_extension.rb +27 -0
- data/vendor/mustache/lib/rack/bug/panels/mustache_panel/view.mustache +46 -0
- data/vendor/mustache/man/mustache.1 +180 -0
- data/vendor/mustache/man/mustache.1.html +204 -0
- data/vendor/mustache/man/mustache.1.ron +127 -0
- data/vendor/mustache/man/mustache.5 +576 -0
- data/vendor/mustache/man/mustache.5.html +415 -0
- data/vendor/mustache/man/mustache.5.ron +324 -0
- data/vendor/mustache/mustache.gemspec +32 -0
- data/vendor/mustache/test/autoloading_test.rb +52 -0
- data/vendor/mustache/test/fixtures/comments.mustache +1 -0
- data/vendor/mustache/test/fixtures/comments.rb +14 -0
- data/vendor/mustache/test/fixtures/complex_view.mustache +17 -0
- data/vendor/mustache/test/fixtures/complex_view.rb +34 -0
- data/vendor/mustache/test/fixtures/crazy_recursive.mustache +9 -0
- data/vendor/mustache/test/fixtures/crazy_recursive.rb +31 -0
- data/vendor/mustache/test/fixtures/delimiters.mustache +8 -0
- data/vendor/mustache/test/fixtures/delimiters.rb +23 -0
- data/vendor/mustache/test/fixtures/double_section.mustache +7 -0
- data/vendor/mustache/test/fixtures/double_section.rb +14 -0
- data/vendor/mustache/test/fixtures/escaped.mustache +1 -0
- data/vendor/mustache/test/fixtures/escaped.rb +14 -0
- data/vendor/mustache/test/fixtures/inner_partial.mustache +1 -0
- data/vendor/mustache/test/fixtures/inner_partial.txt +1 -0
- data/vendor/mustache/test/fixtures/inverted_section.mustache +7 -0
- data/vendor/mustache/test/fixtures/inverted_section.rb +14 -0
- data/vendor/mustache/test/fixtures/lambda.mustache +7 -0
- data/vendor/mustache/test/fixtures/lambda.rb +31 -0
- data/vendor/mustache/test/fixtures/namespaced.mustache +1 -0
- data/vendor/mustache/test/fixtures/namespaced.rb +25 -0
- data/vendor/mustache/test/fixtures/nested_objects.mustache +17 -0
- data/vendor/mustache/test/fixtures/nested_objects.rb +35 -0
- data/vendor/mustache/test/fixtures/node.mustache +8 -0
- data/vendor/mustache/test/fixtures/partial_with_module.mustache +3 -0
- data/vendor/mustache/test/fixtures/partial_with_module.rb +37 -0
- data/vendor/mustache/test/fixtures/passenger.conf +5 -0
- data/vendor/mustache/test/fixtures/passenger.rb +27 -0
- data/vendor/mustache/test/fixtures/recursive.mustache +4 -0
- data/vendor/mustache/test/fixtures/recursive.rb +14 -0
- data/vendor/mustache/test/fixtures/simple.mustache +5 -0
- data/vendor/mustache/test/fixtures/simple.rb +26 -0
- data/vendor/mustache/test/fixtures/template_partial.mustache +2 -0
- data/vendor/mustache/test/fixtures/template_partial.rb +18 -0
- data/vendor/mustache/test/fixtures/template_partial.txt +4 -0
- data/vendor/mustache/test/fixtures/unescaped.mustache +1 -0
- data/vendor/mustache/test/fixtures/unescaped.rb +14 -0
- data/vendor/mustache/test/fixtures/utf8.mustache +3 -0
- data/vendor/mustache/test/fixtures/utf8_partial.mustache +1 -0
- data/vendor/mustache/test/helper.rb +7 -0
- data/vendor/mustache/test/mustache_test.rb +536 -0
- data/vendor/mustache/test/parser_test.rb +54 -0
- data/vendor/mustache/test/partial_test.rb +168 -0
- metadata +167 -0
@@ -0,0 +1,204 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta http-equiv='content-type' value='text/html;charset=utf8'>
|
5
|
+
<meta name='generator' value='Ronn/v0.5'>
|
6
|
+
<title>mustache(1) -- Mustache processor</title>
|
7
|
+
<style type='text/css'>
|
8
|
+
body {margin:0}
|
9
|
+
#man, #man code, #man pre, #man tt, #man kbd, #man samp {
|
10
|
+
font-family:consolas,monospace;
|
11
|
+
font-size:16px;
|
12
|
+
line-height:1.3;
|
13
|
+
color:#343331;
|
14
|
+
background:#fff; }
|
15
|
+
#man { max-width:89ex; text-align:justify; margin:0 25px 25px 25px }
|
16
|
+
#man h1, #man h2, #man h3 { color:#232221;clear:left }
|
17
|
+
#man h1 { font-size:28px; margin:15px 0 30px 0; text-align:center }
|
18
|
+
#man h2 { font-size:18px; margin-bottom:0; margin-top:10px; line-height:1.3; }
|
19
|
+
#man h3 { font-size:16px; margin:0 0 0 4ex; }
|
20
|
+
#man p, #man ul, #man ol, #man dl, #man pre { margin:0 0 18px 0; }
|
21
|
+
#man pre {
|
22
|
+
color:#333231;
|
23
|
+
background:#edeceb;
|
24
|
+
padding:5px 7px;
|
25
|
+
margin:0px 0 20px 0;
|
26
|
+
border-left:2ex solid #ddd}
|
27
|
+
#man pre + h2, #man pre + h3 {
|
28
|
+
margin-top:22px;
|
29
|
+
}
|
30
|
+
#man h2 + pre, #man h3 + pre {
|
31
|
+
margin-top:5px;
|
32
|
+
}
|
33
|
+
#man > p, #man > ul, #man > ol, #man > dl, #man > pre { margin-left:8ex; }
|
34
|
+
#man dt { margin:0; clear:left }
|
35
|
+
#man dt.flush { float:left; width:8ex }
|
36
|
+
#man dd { margin:0 0 0 9ex }
|
37
|
+
#man code, #man strong, #man b { font-weight:bold; color:#131211; }
|
38
|
+
#man pre code { font-weight:normal; color:#232221; background:inherit }
|
39
|
+
#man em, var, u {
|
40
|
+
font-style:normal; color:#333231; border-bottom:1px solid #999; }
|
41
|
+
#man h1.man-title { display:none; }
|
42
|
+
#man ol.man, #man ol.man li { margin:2px 0 10px 0; padding:0;
|
43
|
+
float:left; width:33%; list-style-type:none;
|
44
|
+
text-transform:uppercase; font-size:18px; color:#999;
|
45
|
+
letter-spacing:1px;}
|
46
|
+
#man ol.man { width:100%; }
|
47
|
+
#man ol.man li.tl { text-align:left }
|
48
|
+
#man ol.man li.tc { text-align:center;letter-spacing:4px }
|
49
|
+
#man ol.man li.tr { text-align:right }
|
50
|
+
#man ol.man a { color:#999 }
|
51
|
+
#man ol.man a:hover { color:#333231 }
|
52
|
+
</style>
|
53
|
+
</head>
|
54
|
+
<body>
|
55
|
+
<div id='man'>
|
56
|
+
|
57
|
+
<h1 class='man-title'>mustache(1)</h1>
|
58
|
+
|
59
|
+
<ol class='head man'>
|
60
|
+
<li class='tl'>mustache(1)</li>
|
61
|
+
<li class='tc'>Mustache Manual</li>
|
62
|
+
<li class='tr'>mustache(1)</li>
|
63
|
+
</ol>
|
64
|
+
|
65
|
+
<h2 id='NAME'>NAME</h2>
|
66
|
+
<p><code>mustache</code> -- Mustache processor</p>
|
67
|
+
|
68
|
+
<h2>SYNOPSIS</h2>
|
69
|
+
|
70
|
+
<pre><code>mustache <YAML> <FILE>
|
71
|
+
mustache --compile <FILE>
|
72
|
+
mustache --tokens <FILE>
|
73
|
+
</code></pre>
|
74
|
+
|
75
|
+
<h2>DESCRIPTION</h2>
|
76
|
+
|
77
|
+
<p>Mustache is a logic-less templating system for HTML, config files,
|
78
|
+
anything.</p>
|
79
|
+
|
80
|
+
<p>The <code>mustache</code> command processes a Mustache template preceded by YAML
|
81
|
+
frontmatter from standard input and prints one or more documents to
|
82
|
+
standard output.</p>
|
83
|
+
|
84
|
+
<p>YAML frontmatter beings with <code>---</code> on a single line, followed by YAML,
|
85
|
+
ending with another <code>---</code> on a single line, e.g.</p>
|
86
|
+
|
87
|
+
<pre><code>---
|
88
|
+
names: [ {name: chris}, {name: mark}, {name: scott} ]
|
89
|
+
---
|
90
|
+
</code></pre>
|
91
|
+
|
92
|
+
<p>If you are unfamiliar with YAML, it is a superset of JSON. Valid JSON
|
93
|
+
should work fine.</p>
|
94
|
+
|
95
|
+
<p>After the frontmatter should come any valid Mustache template. See
|
96
|
+
mustache(5) for an overview of Mustache templates.</p>
|
97
|
+
|
98
|
+
<p>For example:</p>
|
99
|
+
|
100
|
+
<pre><code>{{#names}}
|
101
|
+
Hi {{name}}!
|
102
|
+
{{/names}}
|
103
|
+
</code></pre>
|
104
|
+
|
105
|
+
<p>Now let's combine them.</p>
|
106
|
+
|
107
|
+
<pre><code>$ cat data.yml
|
108
|
+
---
|
109
|
+
names: [ {name: chris}, {name: mark}, {name: scott} ]
|
110
|
+
---
|
111
|
+
|
112
|
+
$ cat template.mustache
|
113
|
+
{{#names}}
|
114
|
+
Hi {{name}}!
|
115
|
+
{{/names}}
|
116
|
+
|
117
|
+
$ cat data.yml template.mustache | mustache
|
118
|
+
Hi chris!
|
119
|
+
Hi mark!
|
120
|
+
Hi scott!
|
121
|
+
</code></pre>
|
122
|
+
|
123
|
+
<p>If you provide multiple YAML documents (as delimited by <code>---</code>), your
|
124
|
+
template will be rendered multiple times. Like a mail merge.</p>
|
125
|
+
|
126
|
+
<p>For example:</p>
|
127
|
+
|
128
|
+
<pre><code>$ cat data.yml
|
129
|
+
---
|
130
|
+
name: chris
|
131
|
+
---
|
132
|
+
name: mark
|
133
|
+
---
|
134
|
+
name: scott
|
135
|
+
---
|
136
|
+
|
137
|
+
$ cat template.mustache
|
138
|
+
Hi {{name}}!
|
139
|
+
|
140
|
+
$ cat data.yml template.mustache | mustache
|
141
|
+
Hi chris!
|
142
|
+
Hi mark!
|
143
|
+
Hi scott!
|
144
|
+
</code></pre>
|
145
|
+
|
146
|
+
<h2>OPTIONS</h2>
|
147
|
+
|
148
|
+
<p>By default <code>mustache</code> will try to render a Mustache template using the
|
149
|
+
YAML frontmatter you provide. It can do a few other things, however.</p>
|
150
|
+
|
151
|
+
<dl>
|
152
|
+
<dt><code>-c</code>, <code>--compile</code></dt><dd><p>Print the compiled Ruby version of a given template. This is the
|
153
|
+
code that is actually used when rendering a template into a
|
154
|
+
string. Useful for debugging but only if you are familiar with
|
155
|
+
Mustache's internals.</p></dd>
|
156
|
+
<dt><code>-t</code>, <code>--tokens</code></dt><dd><p>Print the tokenized form of a given Mustache template. This can be
|
157
|
+
used to understand how Mustache parses a template. The tokens are
|
158
|
+
handed to a generator which compiles them into a Ruby
|
159
|
+
string. Syntax errors and confused tags, therefor, can probably be
|
160
|
+
identified by examining the tokens produced.</p></dd>
|
161
|
+
</dl>
|
162
|
+
|
163
|
+
|
164
|
+
<h2>INSTALLATION</h2>
|
165
|
+
|
166
|
+
<p>If you have RubyGems installed:</p>
|
167
|
+
|
168
|
+
<pre><code>gem install mustache
|
169
|
+
</code></pre>
|
170
|
+
|
171
|
+
<h2>EXAMPLES</h2>
|
172
|
+
|
173
|
+
<pre><code>$ mustache data.yml template.mustache
|
174
|
+
$ cat data.yml | mustache - template.mustache
|
175
|
+
$ mustache -c template.mustache
|
176
|
+
$ cat <<data | ruby mustache - template.mustache
|
177
|
+
---
|
178
|
+
name: Bob
|
179
|
+
age: 30
|
180
|
+
---
|
181
|
+
data
|
182
|
+
</code></pre>
|
183
|
+
|
184
|
+
<h2>COPYRIGHT</h2>
|
185
|
+
|
186
|
+
<p>Mustache is Copyright (C) 2009 Chris Wanstrath</p>
|
187
|
+
|
188
|
+
<p>Original CTemplate by Google</p>
|
189
|
+
|
190
|
+
<h2>SEE ALSO</h2>
|
191
|
+
|
192
|
+
<p>mustache(5), mustache(7), gem(1),
|
193
|
+
<a href="http://mustache.github.com/">http://mustache.github.com/</a></p>
|
194
|
+
|
195
|
+
|
196
|
+
<ol class='foot man'>
|
197
|
+
<li class='tl'>DEFUNKT</li>
|
198
|
+
<li class='tc'>May 2010</li>
|
199
|
+
<li class='tr'>mustache(1)</li>
|
200
|
+
</ol>
|
201
|
+
|
202
|
+
</div>
|
203
|
+
</body>
|
204
|
+
</html>
|
@@ -0,0 +1,127 @@
|
|
1
|
+
mustache(1) -- Mustache processor
|
2
|
+
=================================
|
3
|
+
|
4
|
+
## SYNOPSIS
|
5
|
+
|
6
|
+
mustache <YAML> <FILE>
|
7
|
+
mustache --compile <FILE>
|
8
|
+
mustache --tokens <FILE>
|
9
|
+
|
10
|
+
|
11
|
+
## DESCRIPTION
|
12
|
+
|
13
|
+
Mustache is a logic-less templating system for HTML, config files,
|
14
|
+
anything.
|
15
|
+
|
16
|
+
The `mustache` command processes a Mustache template preceded by YAML
|
17
|
+
frontmatter from standard input and prints one or more documents to
|
18
|
+
standard output.
|
19
|
+
|
20
|
+
YAML frontmatter beings with `---` on a single line, followed by YAML,
|
21
|
+
ending with another `---` on a single line, e.g.
|
22
|
+
|
23
|
+
---
|
24
|
+
names: [ {name: chris}, {name: mark}, {name: scott} ]
|
25
|
+
---
|
26
|
+
|
27
|
+
If you are unfamiliar with YAML, it is a superset of JSON. Valid JSON
|
28
|
+
should work fine.
|
29
|
+
|
30
|
+
After the frontmatter should come any valid Mustache template. See
|
31
|
+
mustache(5) for an overview of Mustache templates.
|
32
|
+
|
33
|
+
For example:
|
34
|
+
|
35
|
+
{{#names}}
|
36
|
+
Hi {{name}}!
|
37
|
+
{{/names}}
|
38
|
+
|
39
|
+
Now let's combine them.
|
40
|
+
|
41
|
+
$ cat data.yml
|
42
|
+
---
|
43
|
+
names: [ {name: chris}, {name: mark}, {name: scott} ]
|
44
|
+
---
|
45
|
+
|
46
|
+
$ cat template.mustache
|
47
|
+
{{#names}}
|
48
|
+
Hi {{name}}!
|
49
|
+
{{/names}}
|
50
|
+
|
51
|
+
$ cat data.yml template.mustache | mustache
|
52
|
+
Hi chris!
|
53
|
+
Hi mark!
|
54
|
+
Hi scott!
|
55
|
+
|
56
|
+
If you provide multiple YAML documents (as delimited by `---`), your
|
57
|
+
template will be rendered multiple times. Like a mail merge.
|
58
|
+
|
59
|
+
For example:
|
60
|
+
|
61
|
+
$ cat data.yml
|
62
|
+
---
|
63
|
+
name: chris
|
64
|
+
---
|
65
|
+
name: mark
|
66
|
+
---
|
67
|
+
name: scott
|
68
|
+
---
|
69
|
+
|
70
|
+
$ cat template.mustache
|
71
|
+
Hi {{name}}!
|
72
|
+
|
73
|
+
$ cat data.yml template.mustache | mustache
|
74
|
+
Hi chris!
|
75
|
+
Hi mark!
|
76
|
+
Hi scott!
|
77
|
+
|
78
|
+
## OPTIONS
|
79
|
+
|
80
|
+
By default `mustache` will try to render a Mustache template using the
|
81
|
+
YAML frontmatter you provide. It can do a few other things, however.
|
82
|
+
|
83
|
+
* `-c`, `--compile`:
|
84
|
+
Print the compiled Ruby version of a given template. This is the
|
85
|
+
code that is actually used when rendering a template into a
|
86
|
+
string. Useful for debugging but only if you are familiar with
|
87
|
+
Mustache's internals.
|
88
|
+
|
89
|
+
* `-t`, `--tokens`:
|
90
|
+
Print the tokenized form of a given Mustache template. This can be
|
91
|
+
used to understand how Mustache parses a template. The tokens are
|
92
|
+
handed to a generator which compiles them into a Ruby
|
93
|
+
string. Syntax errors and confused tags, therefor, can probably be
|
94
|
+
identified by examining the tokens produced.
|
95
|
+
|
96
|
+
|
97
|
+
## INSTALLATION
|
98
|
+
|
99
|
+
If you have RubyGems installed:
|
100
|
+
|
101
|
+
gem install mustache
|
102
|
+
|
103
|
+
|
104
|
+
## EXAMPLES
|
105
|
+
|
106
|
+
$ mustache data.yml template.mustache
|
107
|
+
$ cat data.yml | mustache - template.mustache
|
108
|
+
$ mustache -c template.mustache
|
109
|
+
$ cat <<data | ruby mustache - template.mustache
|
110
|
+
---
|
111
|
+
name: Bob
|
112
|
+
age: 30
|
113
|
+
---
|
114
|
+
data
|
115
|
+
|
116
|
+
|
117
|
+
## COPYRIGHT
|
118
|
+
|
119
|
+
Mustache is Copyright (C) 2009 Chris Wanstrath
|
120
|
+
|
121
|
+
Original CTemplate by Google
|
122
|
+
|
123
|
+
|
124
|
+
## SEE ALSO
|
125
|
+
|
126
|
+
mustache(5), mustache(7), gem(1),
|
127
|
+
<http://mustache.github.com/>
|
@@ -0,0 +1,576 @@
|
|
1
|
+
.\" generated with Ronn/v0.5
|
2
|
+
.\" http://github.com/rtomayko/ronn/
|
3
|
+
.
|
4
|
+
.TH "MUSTACHE" "5" "May 2010" "DEFUNKT" "Mustache Manual"
|
5
|
+
.
|
6
|
+
.SH "NAME"
|
7
|
+
\fBmustache\fR \-\- Logic\-less templates.
|
8
|
+
.
|
9
|
+
.SH "SYNOPSIS"
|
10
|
+
A typical Mustache template:
|
11
|
+
.
|
12
|
+
.IP "" 4
|
13
|
+
.
|
14
|
+
.nf
|
15
|
+
|
16
|
+
Hello {{name}}
|
17
|
+
You have just won {{value}} dollars!
|
18
|
+
{{#in_ca}}
|
19
|
+
Well, {{taxed_value}} dollars, after taxes.
|
20
|
+
{{/in_ca}}
|
21
|
+
.
|
22
|
+
.fi
|
23
|
+
.
|
24
|
+
.IP "" 0
|
25
|
+
.
|
26
|
+
.P
|
27
|
+
Given the following hash:
|
28
|
+
.
|
29
|
+
.IP "" 4
|
30
|
+
.
|
31
|
+
.nf
|
32
|
+
|
33
|
+
{
|
34
|
+
"name": "Chris",
|
35
|
+
"value": 10000,
|
36
|
+
"taxed_value": 10000 \- (10000 * 0.4),
|
37
|
+
"in_ca": true
|
38
|
+
}
|
39
|
+
.
|
40
|
+
.fi
|
41
|
+
.
|
42
|
+
.IP "" 0
|
43
|
+
.
|
44
|
+
.P
|
45
|
+
Will produce the following:
|
46
|
+
.
|
47
|
+
.IP "" 4
|
48
|
+
.
|
49
|
+
.nf
|
50
|
+
|
51
|
+
Hello Chris
|
52
|
+
You have just won 10000 dollars!
|
53
|
+
Well, 6000.0 dollars, after taxes.
|
54
|
+
.
|
55
|
+
.fi
|
56
|
+
.
|
57
|
+
.IP "" 0
|
58
|
+
.
|
59
|
+
.SH "DESCRIPTION"
|
60
|
+
Mustache can be used for HTML, config files, source code \-
|
61
|
+
anything. It works by expanding tags in a template using values
|
62
|
+
provided in a hash or object.
|
63
|
+
.
|
64
|
+
.P
|
65
|
+
We call it "logic\-less" because there are no if statements, else
|
66
|
+
clauses, or for loops. Instead there are only tags. Some tags are
|
67
|
+
replaced with a value, some nothing, and others a series of
|
68
|
+
values. This document explains the different types of Mustache tags.
|
69
|
+
.
|
70
|
+
.SH "TAG TYPES"
|
71
|
+
Tags are indicated by the double mustaches. \fB{{person}}\fR is a tag, as
|
72
|
+
is \fB{{#person}}\fR. In both examples, we'd refer to \fBperson\fR as the key
|
73
|
+
or tag key. Let's talk about the different types of tags.
|
74
|
+
.
|
75
|
+
.SS "Variables"
|
76
|
+
The most basic tag type is the variable. A \fB{{name}}\fR tag in a basic
|
77
|
+
template will try to find the \fBname\fR key in the current context. If
|
78
|
+
there is no \fBname\fR key, nothing will be rendered.
|
79
|
+
.
|
80
|
+
.P
|
81
|
+
All variables are HTML escaped by default. If you want to return
|
82
|
+
unescaped HTML, use the triple mustache: \fB{{{name}}}\fR.
|
83
|
+
.
|
84
|
+
.P
|
85
|
+
You can also use \fB&\fR to unescape a variable: \fB{{& name}}\fR. This may be
|
86
|
+
useful when changing delimiters (see "Set Delimiter" below).
|
87
|
+
.
|
88
|
+
.P
|
89
|
+
By default a variable "miss" returns an empty string. This can usually
|
90
|
+
be configured in your Mustache library. The Ruby version of Mustache
|
91
|
+
supports raising an exception in this situation, for instance.
|
92
|
+
.
|
93
|
+
.P
|
94
|
+
Template:
|
95
|
+
.
|
96
|
+
.IP "" 4
|
97
|
+
.
|
98
|
+
.nf
|
99
|
+
|
100
|
+
* {{name}}
|
101
|
+
* {{age}}
|
102
|
+
* {{company}}
|
103
|
+
* {{{company}}}
|
104
|
+
.
|
105
|
+
.fi
|
106
|
+
.
|
107
|
+
.IP "" 0
|
108
|
+
.
|
109
|
+
.P
|
110
|
+
Hash:
|
111
|
+
.
|
112
|
+
.IP "" 4
|
113
|
+
.
|
114
|
+
.nf
|
115
|
+
|
116
|
+
{
|
117
|
+
"name": "Chris",
|
118
|
+
"company": "<b>GitHub</b>"
|
119
|
+
}
|
120
|
+
.
|
121
|
+
.fi
|
122
|
+
.
|
123
|
+
.IP "" 0
|
124
|
+
.
|
125
|
+
.P
|
126
|
+
Output:
|
127
|
+
.
|
128
|
+
.IP "" 4
|
129
|
+
.
|
130
|
+
.nf
|
131
|
+
|
132
|
+
* Chris
|
133
|
+
*
|
134
|
+
* <b>GitHub</b>
|
135
|
+
* <b>GitHub</b>
|
136
|
+
.
|
137
|
+
.fi
|
138
|
+
.
|
139
|
+
.IP "" 0
|
140
|
+
.
|
141
|
+
.SS "Sections"
|
142
|
+
Sections render blocks of text one or more times, depending on the
|
143
|
+
value of the key in the current context.
|
144
|
+
.
|
145
|
+
.P
|
146
|
+
A section begins with a pound and ends with a slash. That is, \fB{{#person}}\fR begins a "person" section while \fB{{/person}}\fR ends it.
|
147
|
+
.
|
148
|
+
.P
|
149
|
+
The behavior of the section is determined by the value of the key.
|
150
|
+
.
|
151
|
+
.P
|
152
|
+
\fBFalse Values or Empty Lists\fR
|
153
|
+
.
|
154
|
+
.P
|
155
|
+
If the \fBperson\fR key exists and has a value of false or an empty
|
156
|
+
list, the HTML between the pound and slash will not be displayed.
|
157
|
+
.
|
158
|
+
.P
|
159
|
+
Template:
|
160
|
+
.
|
161
|
+
.IP "" 4
|
162
|
+
.
|
163
|
+
.nf
|
164
|
+
|
165
|
+
Shown.
|
166
|
+
{{#nothin}}
|
167
|
+
Never shown!
|
168
|
+
{{/nothin}}
|
169
|
+
.
|
170
|
+
.fi
|
171
|
+
.
|
172
|
+
.IP "" 0
|
173
|
+
.
|
174
|
+
.P
|
175
|
+
Hash:
|
176
|
+
.
|
177
|
+
.IP "" 4
|
178
|
+
.
|
179
|
+
.nf
|
180
|
+
|
181
|
+
{
|
182
|
+
"person": true,
|
183
|
+
}
|
184
|
+
.
|
185
|
+
.fi
|
186
|
+
.
|
187
|
+
.IP "" 0
|
188
|
+
.
|
189
|
+
.P
|
190
|
+
Output:
|
191
|
+
.
|
192
|
+
.IP "" 4
|
193
|
+
.
|
194
|
+
.nf
|
195
|
+
|
196
|
+
Shown.
|
197
|
+
.
|
198
|
+
.fi
|
199
|
+
.
|
200
|
+
.IP "" 0
|
201
|
+
.
|
202
|
+
.P
|
203
|
+
\fBNon\-Empty Lists\fR
|
204
|
+
.
|
205
|
+
.P
|
206
|
+
If the \fBperson\fR key exists and has a non\-false value, the HTML between
|
207
|
+
the pound and slash will be rendered and displayed one or more times.
|
208
|
+
.
|
209
|
+
.P
|
210
|
+
When the value is a non\-empty list, the text in the block will be
|
211
|
+
displayed once for each item in the list. The context of the block
|
212
|
+
will be set to the current item for each iteration. In this way we can
|
213
|
+
loop over collections.
|
214
|
+
.
|
215
|
+
.P
|
216
|
+
Template:
|
217
|
+
.
|
218
|
+
.IP "" 4
|
219
|
+
.
|
220
|
+
.nf
|
221
|
+
|
222
|
+
{{#repo}}
|
223
|
+
<b>{{name}}</b>
|
224
|
+
{{/repo}}
|
225
|
+
.
|
226
|
+
.fi
|
227
|
+
.
|
228
|
+
.IP "" 0
|
229
|
+
.
|
230
|
+
.P
|
231
|
+
Hash:
|
232
|
+
.
|
233
|
+
.IP "" 4
|
234
|
+
.
|
235
|
+
.nf
|
236
|
+
|
237
|
+
{
|
238
|
+
"repo": [
|
239
|
+
{ "name": "resque" },
|
240
|
+
{ "name": "hub" },
|
241
|
+
{ "name": "rip" },
|
242
|
+
]
|
243
|
+
}
|
244
|
+
.
|
245
|
+
.fi
|
246
|
+
.
|
247
|
+
.IP "" 0
|
248
|
+
.
|
249
|
+
.P
|
250
|
+
Output:
|
251
|
+
.
|
252
|
+
.IP "" 4
|
253
|
+
.
|
254
|
+
.nf
|
255
|
+
|
256
|
+
<b>resque</b>
|
257
|
+
<b>hub</b>
|
258
|
+
<b>rip</b>
|
259
|
+
.
|
260
|
+
.fi
|
261
|
+
.
|
262
|
+
.IP "" 0
|
263
|
+
.
|
264
|
+
.P
|
265
|
+
\fBLambdas\fR
|
266
|
+
.
|
267
|
+
.P
|
268
|
+
When the value is a callable object, such as a function or lambda, the
|
269
|
+
object will be invoked and passed the block of text. The text passed
|
270
|
+
is the literal block, unrendered. \fB{{tags}}\fR will not have been expanded
|
271
|
+
\- the lambda should do that on its own. In this way you can implement
|
272
|
+
filters or caching.
|
273
|
+
.
|
274
|
+
.P
|
275
|
+
Template:
|
276
|
+
.
|
277
|
+
.IP "" 4
|
278
|
+
.
|
279
|
+
.nf
|
280
|
+
|
281
|
+
{{#wrapped}}
|
282
|
+
{{name}} is awesome.
|
283
|
+
{{/wrapped}}
|
284
|
+
.
|
285
|
+
.fi
|
286
|
+
.
|
287
|
+
.IP "" 0
|
288
|
+
.
|
289
|
+
.P
|
290
|
+
Hash:
|
291
|
+
.
|
292
|
+
.IP "" 4
|
293
|
+
.
|
294
|
+
.nf
|
295
|
+
|
296
|
+
{
|
297
|
+
"name": "Willy",
|
298
|
+
"wrapped": function() {
|
299
|
+
return function(text) {
|
300
|
+
return "<b>" + render(text) + "</b>"
|
301
|
+
}
|
302
|
+
}
|
303
|
+
}
|
304
|
+
.
|
305
|
+
.fi
|
306
|
+
.
|
307
|
+
.IP "" 0
|
308
|
+
.
|
309
|
+
.P
|
310
|
+
Output:
|
311
|
+
.
|
312
|
+
.IP "" 4
|
313
|
+
.
|
314
|
+
.nf
|
315
|
+
|
316
|
+
<b>Willy is awesome.</b>
|
317
|
+
.
|
318
|
+
.fi
|
319
|
+
.
|
320
|
+
.IP "" 0
|
321
|
+
.
|
322
|
+
.P
|
323
|
+
\fBNon\-False Values\fR
|
324
|
+
.
|
325
|
+
.P
|
326
|
+
When the value is non\-false but not a list, it will be used as the
|
327
|
+
context for a single rendering of the block.
|
328
|
+
.
|
329
|
+
.P
|
330
|
+
Template:
|
331
|
+
.
|
332
|
+
.IP "" 4
|
333
|
+
.
|
334
|
+
.nf
|
335
|
+
|
336
|
+
{{#person?}}
|
337
|
+
Hi {{name}}!
|
338
|
+
{{/person?}}
|
339
|
+
.
|
340
|
+
.fi
|
341
|
+
.
|
342
|
+
.IP "" 0
|
343
|
+
.
|
344
|
+
.P
|
345
|
+
Hash:
|
346
|
+
.
|
347
|
+
.IP "" 4
|
348
|
+
.
|
349
|
+
.nf
|
350
|
+
|
351
|
+
{
|
352
|
+
"person?": { "name": "Jon" }
|
353
|
+
}
|
354
|
+
.
|
355
|
+
.fi
|
356
|
+
.
|
357
|
+
.IP "" 0
|
358
|
+
.
|
359
|
+
.P
|
360
|
+
Output:
|
361
|
+
.
|
362
|
+
.IP "" 4
|
363
|
+
.
|
364
|
+
.nf
|
365
|
+
|
366
|
+
Hi Jon!
|
367
|
+
.
|
368
|
+
.fi
|
369
|
+
.
|
370
|
+
.IP "" 0
|
371
|
+
.
|
372
|
+
.SS "Inverted Sections"
|
373
|
+
An inverted section begins with a caret (hat) and ends with a
|
374
|
+
slash. That is \fB{{^person}}\fR begins a "person" inverted section while \fB{{/person}}\fR ends it.
|
375
|
+
.
|
376
|
+
.P
|
377
|
+
While sections can be used to render text one or more times based on the
|
378
|
+
value of the key, inverted sections may render text once based
|
379
|
+
on the inverse value of the key. That is, they will be rendered
|
380
|
+
if the key doesn't exist, is false, or is an empty list.
|
381
|
+
.
|
382
|
+
.P
|
383
|
+
Template:
|
384
|
+
.
|
385
|
+
.IP "" 4
|
386
|
+
.
|
387
|
+
.nf
|
388
|
+
|
389
|
+
{{#repo}}
|
390
|
+
<b>{{name}}</b>
|
391
|
+
{{/repo}}
|
392
|
+
{{^repo}}
|
393
|
+
No repos :(
|
394
|
+
{{/repo}}
|
395
|
+
.
|
396
|
+
.fi
|
397
|
+
.
|
398
|
+
.IP "" 0
|
399
|
+
.
|
400
|
+
.P
|
401
|
+
Hash:
|
402
|
+
.
|
403
|
+
.IP "" 4
|
404
|
+
.
|
405
|
+
.nf
|
406
|
+
|
407
|
+
{
|
408
|
+
"repo": []
|
409
|
+
}
|
410
|
+
.
|
411
|
+
.fi
|
412
|
+
.
|
413
|
+
.IP "" 0
|
414
|
+
.
|
415
|
+
.P
|
416
|
+
Output:
|
417
|
+
.
|
418
|
+
.IP "" 4
|
419
|
+
.
|
420
|
+
.nf
|
421
|
+
|
422
|
+
No repos :(
|
423
|
+
.
|
424
|
+
.fi
|
425
|
+
.
|
426
|
+
.IP "" 0
|
427
|
+
.
|
428
|
+
.SS "Comments"
|
429
|
+
Comments begin with a bang and are ignored. The following template:
|
430
|
+
.
|
431
|
+
.IP "" 4
|
432
|
+
.
|
433
|
+
.nf
|
434
|
+
|
435
|
+
<h1>Today{{! ignore me }}.</h1>
|
436
|
+
.
|
437
|
+
.fi
|
438
|
+
.
|
439
|
+
.IP "" 0
|
440
|
+
.
|
441
|
+
.P
|
442
|
+
Will render as follows:
|
443
|
+
.
|
444
|
+
.IP "" 4
|
445
|
+
.
|
446
|
+
.nf
|
447
|
+
|
448
|
+
<h1>Today.</h1>
|
449
|
+
.
|
450
|
+
.fi
|
451
|
+
.
|
452
|
+
.IP "" 0
|
453
|
+
.
|
454
|
+
.P
|
455
|
+
Comments may contain newlines.
|
456
|
+
.
|
457
|
+
.SS "Partials"
|
458
|
+
Partials begin with a greater than sign, like \fB{{> box}}\fR.
|
459
|
+
.
|
460
|
+
.P
|
461
|
+
Partials are rendered at runtime (as opposed to compile time), so
|
462
|
+
recursive partials are possible. Just avoid infinite loops.
|
463
|
+
.
|
464
|
+
.P
|
465
|
+
They also inherit the calling context. Whereas in ERB you may have
|
466
|
+
this:
|
467
|
+
.
|
468
|
+
.IP "" 4
|
469
|
+
.
|
470
|
+
.nf
|
471
|
+
|
472
|
+
<%= partial :next_more, :start => start, :size => size %>
|
473
|
+
.
|
474
|
+
.fi
|
475
|
+
.
|
476
|
+
.IP "" 0
|
477
|
+
.
|
478
|
+
.P
|
479
|
+
Mustache requires only this:
|
480
|
+
.
|
481
|
+
.IP "" 4
|
482
|
+
.
|
483
|
+
.nf
|
484
|
+
|
485
|
+
{{> next_more}}
|
486
|
+
.
|
487
|
+
.fi
|
488
|
+
.
|
489
|
+
.IP "" 0
|
490
|
+
.
|
491
|
+
.P
|
492
|
+
Why? Because the \fBnext_more.mustache\fR file will inherit the \fBsize\fR and \fBstart\fR methods from the calling context.
|
493
|
+
.
|
494
|
+
.P
|
495
|
+
In this way you may want to think of partials as includes, or template
|
496
|
+
expansion, even though it's not literally true.
|
497
|
+
.
|
498
|
+
.P
|
499
|
+
For example, this template and partial:
|
500
|
+
.
|
501
|
+
.IP "" 4
|
502
|
+
.
|
503
|
+
.nf
|
504
|
+
|
505
|
+
base.mustache:
|
506
|
+
<h2>Names</h2>
|
507
|
+
{{#names}}
|
508
|
+
{{> user}}
|
509
|
+
{{/names}}
|
510
|
+
|
511
|
+
user.mustache:
|
512
|
+
<strong>{{name}}</strong>
|
513
|
+
.
|
514
|
+
.fi
|
515
|
+
.
|
516
|
+
.IP "" 0
|
517
|
+
.
|
518
|
+
.P
|
519
|
+
Can be thought of as a single, expanded template:
|
520
|
+
.
|
521
|
+
.IP "" 4
|
522
|
+
.
|
523
|
+
.nf
|
524
|
+
|
525
|
+
<h2>Names</h2>
|
526
|
+
{{#names}}
|
527
|
+
<strong>{{name}}</strong>
|
528
|
+
{{/names}}
|
529
|
+
.
|
530
|
+
.fi
|
531
|
+
.
|
532
|
+
.IP "" 0
|
533
|
+
.
|
534
|
+
.SS "Set Delimiter"
|
535
|
+
Set Delimiter tags start with an equal sign and change the tag
|
536
|
+
delimiters from \fB{{\fR and \fB}}\fR to custom strings.
|
537
|
+
.
|
538
|
+
.P
|
539
|
+
Consider the following contrived example:
|
540
|
+
.
|
541
|
+
.IP "" 4
|
542
|
+
.
|
543
|
+
.nf
|
544
|
+
|
545
|
+
* {{default_tags}}
|
546
|
+
{{=<% %>=}}
|
547
|
+
* <% erb_style_tags %>
|
548
|
+
<%={{ }}=%>
|
549
|
+
* {{ default_tags_again }}
|
550
|
+
.
|
551
|
+
.fi
|
552
|
+
.
|
553
|
+
.IP "" 0
|
554
|
+
.
|
555
|
+
.P
|
556
|
+
Here we have a list with three items. The first item uses the default
|
557
|
+
tag style, the second uses erb style as defined by the Set Delimiter
|
558
|
+
tag, and the third returns to the default style after yet another Set
|
559
|
+
Delimiter declaration.
|
560
|
+
.
|
561
|
+
.P
|
562
|
+
According to \fIctemplates\fR, this "is useful for languages like TeX, where
|
563
|
+
double\-braces may occur in the text and are awkward to use for
|
564
|
+
markup."
|
565
|
+
.
|
566
|
+
.P
|
567
|
+
Custom delimiters may not contain whitespace or the equals sign.
|
568
|
+
.
|
569
|
+
.SH "COPYRIGHT"
|
570
|
+
Mustache is Copyright (C) 2009 Chris Wanstrath
|
571
|
+
.
|
572
|
+
.P
|
573
|
+
Original CTemplate by Google
|
574
|
+
.
|
575
|
+
.SH "SEE ALSO"
|
576
|
+
mustache(1), mustache(7), \fIhttp://mustache.github.com/\fR
|