angry_mob_common_targets 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. data/LICENSE +21 -0
  2. data/README.md +38 -0
  3. data/lib/common_mob.rb +9 -0
  4. data/lib/common_mob/digest.rb +43 -0
  5. data/lib/common_mob/erb.rb +72 -0
  6. data/lib/common_mob/file.rb +55 -0
  7. data/lib/common_mob/patch.rb +51 -0
  8. data/lib/common_mob/resource_locator.rb +9 -0
  9. data/lib/common_mob/shell.rb +323 -0
  10. data/lib/common_mob/template.rb +23 -0
  11. data/lib/common_mob/version.rb +3 -0
  12. data/targets/crontab_patch.rb +37 -0
  13. data/targets/extract.rb +40 -0
  14. data/targets/fetch.rb +40 -0
  15. data/targets/files.rb +244 -0
  16. data/targets/git.rb +84 -0
  17. data/targets/group.rb +33 -0
  18. data/targets/packages.rb +94 -0
  19. data/targets/ruby.rb +13 -0
  20. data/targets/services.rb +184 -0
  21. data/targets/shell.rb +43 -0
  22. data/targets/user.rb +108 -0
  23. data/vendor/mustache/CONTRIBUTORS +9 -0
  24. data/vendor/mustache/HISTORY.md +135 -0
  25. data/vendor/mustache/LICENSE +20 -0
  26. data/vendor/mustache/README.md +405 -0
  27. data/vendor/mustache/Rakefile +103 -0
  28. data/vendor/mustache/benchmarks/complex.erb +15 -0
  29. data/vendor/mustache/benchmarks/complex.haml +12 -0
  30. data/vendor/mustache/benchmarks/helper.rb +20 -0
  31. data/vendor/mustache/benchmarks/simple.erb +5 -0
  32. data/vendor/mustache/benchmarks/speed.rb +78 -0
  33. data/vendor/mustache/bin/mustache +90 -0
  34. data/vendor/mustache/contrib/mustache-mode.el +278 -0
  35. data/vendor/mustache/contrib/mustache.vim +69 -0
  36. data/vendor/mustache/examples/hash.rb +16 -0
  37. data/vendor/mustache/examples/hash.yml +5 -0
  38. data/vendor/mustache/examples/projects.mustache +26 -0
  39. data/vendor/mustache/examples/projects.yml +28 -0
  40. data/vendor/mustache/examples/self.mustache +4 -0
  41. data/vendor/mustache/examples/self.yml +3 -0
  42. data/vendor/mustache/examples/simple.mustache +10 -0
  43. data/vendor/mustache/examples/simple.rb +24 -0
  44. data/vendor/mustache/lib/mustache.rb +358 -0
  45. data/vendor/mustache/lib/mustache/context.rb +108 -0
  46. data/vendor/mustache/lib/mustache/generator.rb +160 -0
  47. data/vendor/mustache/lib/mustache/parser.rb +230 -0
  48. data/vendor/mustache/lib/mustache/sinatra.rb +180 -0
  49. data/vendor/mustache/lib/mustache/template.rb +59 -0
  50. data/vendor/mustache/lib/mustache/version.rb +3 -0
  51. data/vendor/mustache/lib/rack/bug/panels/mustache_panel.rb +81 -0
  52. data/vendor/mustache/lib/rack/bug/panels/mustache_panel/mustache_extension.rb +27 -0
  53. data/vendor/mustache/lib/rack/bug/panels/mustache_panel/view.mustache +46 -0
  54. data/vendor/mustache/man/mustache.1 +180 -0
  55. data/vendor/mustache/man/mustache.1.html +204 -0
  56. data/vendor/mustache/man/mustache.1.ron +127 -0
  57. data/vendor/mustache/man/mustache.5 +576 -0
  58. data/vendor/mustache/man/mustache.5.html +415 -0
  59. data/vendor/mustache/man/mustache.5.ron +324 -0
  60. data/vendor/mustache/mustache.gemspec +32 -0
  61. data/vendor/mustache/test/autoloading_test.rb +52 -0
  62. data/vendor/mustache/test/fixtures/comments.mustache +1 -0
  63. data/vendor/mustache/test/fixtures/comments.rb +14 -0
  64. data/vendor/mustache/test/fixtures/complex_view.mustache +17 -0
  65. data/vendor/mustache/test/fixtures/complex_view.rb +34 -0
  66. data/vendor/mustache/test/fixtures/crazy_recursive.mustache +9 -0
  67. data/vendor/mustache/test/fixtures/crazy_recursive.rb +31 -0
  68. data/vendor/mustache/test/fixtures/delimiters.mustache +8 -0
  69. data/vendor/mustache/test/fixtures/delimiters.rb +23 -0
  70. data/vendor/mustache/test/fixtures/double_section.mustache +7 -0
  71. data/vendor/mustache/test/fixtures/double_section.rb +14 -0
  72. data/vendor/mustache/test/fixtures/escaped.mustache +1 -0
  73. data/vendor/mustache/test/fixtures/escaped.rb +14 -0
  74. data/vendor/mustache/test/fixtures/inner_partial.mustache +1 -0
  75. data/vendor/mustache/test/fixtures/inner_partial.txt +1 -0
  76. data/vendor/mustache/test/fixtures/inverted_section.mustache +7 -0
  77. data/vendor/mustache/test/fixtures/inverted_section.rb +14 -0
  78. data/vendor/mustache/test/fixtures/lambda.mustache +7 -0
  79. data/vendor/mustache/test/fixtures/lambda.rb +31 -0
  80. data/vendor/mustache/test/fixtures/namespaced.mustache +1 -0
  81. data/vendor/mustache/test/fixtures/namespaced.rb +25 -0
  82. data/vendor/mustache/test/fixtures/nested_objects.mustache +17 -0
  83. data/vendor/mustache/test/fixtures/nested_objects.rb +35 -0
  84. data/vendor/mustache/test/fixtures/node.mustache +8 -0
  85. data/vendor/mustache/test/fixtures/partial_with_module.mustache +3 -0
  86. data/vendor/mustache/test/fixtures/partial_with_module.rb +37 -0
  87. data/vendor/mustache/test/fixtures/passenger.conf +5 -0
  88. data/vendor/mustache/test/fixtures/passenger.rb +27 -0
  89. data/vendor/mustache/test/fixtures/recursive.mustache +4 -0
  90. data/vendor/mustache/test/fixtures/recursive.rb +14 -0
  91. data/vendor/mustache/test/fixtures/simple.mustache +5 -0
  92. data/vendor/mustache/test/fixtures/simple.rb +26 -0
  93. data/vendor/mustache/test/fixtures/template_partial.mustache +2 -0
  94. data/vendor/mustache/test/fixtures/template_partial.rb +18 -0
  95. data/vendor/mustache/test/fixtures/template_partial.txt +4 -0
  96. data/vendor/mustache/test/fixtures/unescaped.mustache +1 -0
  97. data/vendor/mustache/test/fixtures/unescaped.rb +14 -0
  98. data/vendor/mustache/test/fixtures/utf8.mustache +3 -0
  99. data/vendor/mustache/test/fixtures/utf8_partial.mustache +1 -0
  100. data/vendor/mustache/test/helper.rb +7 -0
  101. data/vendor/mustache/test/mustache_test.rb +536 -0
  102. data/vendor/mustache/test/parser_test.rb +54 -0
  103. data/vendor/mustache/test/partial_test.rb +168 -0
  104. metadata +167 -0
@@ -0,0 +1,415 @@
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(5) -- Logic-less templates.</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(5)</h1>
58
+
59
+ <ol class='head man'>
60
+ <li class='tl'>mustache(5)</li>
61
+ <li class='tc'>Mustache Manual</li>
62
+ <li class='tr'>mustache(5)</li>
63
+ </ol>
64
+
65
+ <h2 id='NAME'>NAME</h2>
66
+ <p><code>mustache</code> -- Logic-less templates.</p>
67
+
68
+ <h2>SYNOPSIS</h2>
69
+
70
+ <p>A typical Mustache template:</p>
71
+
72
+ <pre><code>Hello {{name}}
73
+ You have just won {{value}} dollars!
74
+ {{#in_ca}}
75
+ Well, {{taxed_value}} dollars, after taxes.
76
+ {{/in_ca}}
77
+ </code></pre>
78
+
79
+ <p>Given the following hash:</p>
80
+
81
+ <pre><code>{
82
+ "name": "Chris",
83
+ "value": 10000,
84
+ "taxed_value": 10000 - (10000 * 0.4),
85
+ "in_ca": true
86
+ }
87
+ </code></pre>
88
+
89
+ <p>Will produce the following:</p>
90
+
91
+ <pre><code>Hello Chris
92
+ You have just won 10000 dollars!
93
+ Well, 6000.0 dollars, after taxes.
94
+ </code></pre>
95
+
96
+ <h2>DESCRIPTION</h2>
97
+
98
+ <p>Mustache can be used for HTML, config files, source code -
99
+ anything. It works by expanding tags in a template using values
100
+ provided in a hash or object.</p>
101
+
102
+ <p>We call it "logic-less" because there are no if statements, else
103
+ clauses, or for loops. Instead there are only tags. Some tags are
104
+ replaced with a value, some nothing, and others a series of
105
+ values. This document explains the different types of Mustache tags.</p>
106
+
107
+ <h2>TAG TYPES</h2>
108
+
109
+ <p>Tags are indicated by the double mustaches. <code>{{person}}</code> is a tag, as
110
+ is <code>{{#person}}</code>. In both examples, we'd refer to <code>person</code> as the key
111
+ or tag key. Let's talk about the different types of tags.</p>
112
+
113
+ <h3>Variables</h3>
114
+
115
+ <p>The most basic tag type is the variable. A <code>{{name}}</code> tag in a basic
116
+ template will try to find the <code>name</code> key in the current context. If
117
+ there is no <code>name</code> key, nothing will be rendered.</p>
118
+
119
+ <p>All variables are HTML escaped by default. If you want to return
120
+ unescaped HTML, use the triple mustache: <code>{{{name}}}</code>.</p>
121
+
122
+ <p>You can also use <code>&amp;</code> to unescape a variable: <code>{{&amp; name}}</code>. This may be
123
+ useful when changing delimiters (see "Set Delimiter" below).</p>
124
+
125
+ <p>By default a variable "miss" returns an empty string. This can usually
126
+ be configured in your Mustache library. The Ruby version of Mustache
127
+ supports raising an exception in this situation, for instance.</p>
128
+
129
+ <p>Template:</p>
130
+
131
+ <pre><code>* {{name}}
132
+ * {{age}}
133
+ * {{company}}
134
+ * {{{company}}}
135
+ </code></pre>
136
+
137
+ <p>Hash:</p>
138
+
139
+ <pre><code>{
140
+ "name": "Chris",
141
+ "company": "&lt;b&gt;GitHub&lt;/b&gt;"
142
+ }
143
+ </code></pre>
144
+
145
+ <p>Output:</p>
146
+
147
+ <pre><code>* Chris
148
+ *
149
+ * &amp;lt;b&amp;gt;GitHub&amp;lt;/b&amp;gt;
150
+ * &lt;b&gt;GitHub&lt;/b&gt;
151
+ </code></pre>
152
+
153
+ <h3>Sections</h3>
154
+
155
+ <p>Sections render blocks of text one or more times, depending on the
156
+ value of the key in the current context.</p>
157
+
158
+ <p>A section begins with a pound and ends with a slash. That is,
159
+ <code>{{#person}}</code> begins a "person" section while <code>{{/person}}</code> ends it.</p>
160
+
161
+ <p>The behavior of the section is determined by the value of the key.</p>
162
+
163
+ <p><strong>False Values or Empty Lists</strong></p>
164
+
165
+ <p>If the <code>person</code> key exists and has a value of false or an empty
166
+ list, the HTML between the pound and slash will not be displayed.</p>
167
+
168
+ <p>Template:</p>
169
+
170
+ <pre><code>Shown.
171
+ {{#nothin}}
172
+ Never shown!
173
+ {{/nothin}}
174
+ </code></pre>
175
+
176
+ <p>Hash:</p>
177
+
178
+ <pre><code>{
179
+ "person": true,
180
+ }
181
+ </code></pre>
182
+
183
+ <p>Output:</p>
184
+
185
+ <pre><code>Shown.
186
+ </code></pre>
187
+
188
+ <p><strong>Non-Empty Lists</strong></p>
189
+
190
+ <p>If the <code>person</code> key exists and has a non-false value, the HTML between
191
+ the pound and slash will be rendered and displayed one or more times.</p>
192
+
193
+ <p>When the value is a non-empty list, the text in the block will be
194
+ displayed once for each item in the list. The context of the block
195
+ will be set to the current item for each iteration. In this way we can
196
+ loop over collections.</p>
197
+
198
+ <p>Template:</p>
199
+
200
+ <pre><code>{{#repo}}
201
+ &lt;b&gt;{{name}}&lt;/b&gt;
202
+ {{/repo}}
203
+ </code></pre>
204
+
205
+ <p>Hash:</p>
206
+
207
+ <pre><code>{
208
+ "repo": [
209
+ { "name": "resque" },
210
+ { "name": "hub" },
211
+ { "name": "rip" },
212
+ ]
213
+ }
214
+ </code></pre>
215
+
216
+ <p>Output:</p>
217
+
218
+ <pre><code>&lt;b&gt;resque&lt;/b&gt;
219
+ &lt;b&gt;hub&lt;/b&gt;
220
+ &lt;b&gt;rip&lt;/b&gt;
221
+ </code></pre>
222
+
223
+ <p><strong>Lambdas</strong></p>
224
+
225
+ <p>When the value is a callable object, such as a function or lambda, the
226
+ object will be invoked and passed the block of text. The text passed
227
+ is the literal block, unrendered. <code>{{tags}}</code> will not have been expanded
228
+ - the lambda should do that on its own. In this way you can implement
229
+ filters or caching.</p>
230
+
231
+ <p>Template:</p>
232
+
233
+ <pre><code>{{#wrapped}}
234
+ {{name}} is awesome.
235
+ {{/wrapped}}
236
+ </code></pre>
237
+
238
+ <p>Hash:</p>
239
+
240
+ <pre><code>{
241
+ "name": "Willy",
242
+ "wrapped": function() {
243
+ return function(text) {
244
+ return "&lt;b&gt;" + render(text) + "&lt;/b&gt;"
245
+ }
246
+ }
247
+ }
248
+ </code></pre>
249
+
250
+ <p>Output:</p>
251
+
252
+ <pre><code>&lt;b&gt;Willy is awesome.&lt;/b&gt;
253
+ </code></pre>
254
+
255
+ <p><strong>Non-False Values</strong></p>
256
+
257
+ <p>When the value is non-false but not a list, it will be used as the
258
+ context for a single rendering of the block.</p>
259
+
260
+ <p>Template:</p>
261
+
262
+ <pre><code>{{#person?}}
263
+ Hi {{name}}!
264
+ {{/person?}}
265
+ </code></pre>
266
+
267
+ <p>Hash:</p>
268
+
269
+ <pre><code>{
270
+ "person?": { "name": "Jon" }
271
+ }
272
+ </code></pre>
273
+
274
+ <p>Output:</p>
275
+
276
+ <pre><code>Hi Jon!
277
+ </code></pre>
278
+
279
+ <h3>Inverted Sections</h3>
280
+
281
+ <p>An inverted section begins with a caret (hat) and ends with a
282
+ slash. That is <code>{{^person}}</code> begins a "person" inverted section while
283
+ <code>{{/person}}</code> ends it.</p>
284
+
285
+ <p>While sections can be used to render text one or more times based on the
286
+ value of the key, inverted sections may render text once based
287
+ on the inverse value of the key. That is, they will be rendered
288
+ if the key doesn't exist, is false, or is an empty list.</p>
289
+
290
+ <p>Template:</p>
291
+
292
+ <pre><code>{{#repo}}
293
+ &lt;b&gt;{{name}}&lt;/b&gt;
294
+ {{/repo}}
295
+ {{^repo}}
296
+ No repos :(
297
+ {{/repo}}
298
+ </code></pre>
299
+
300
+ <p>Hash:</p>
301
+
302
+ <pre><code>{
303
+ "repo": []
304
+ }
305
+ </code></pre>
306
+
307
+ <p>Output:</p>
308
+
309
+ <pre><code>No repos :(
310
+ </code></pre>
311
+
312
+ <h3>Comments</h3>
313
+
314
+ <p>Comments begin with a bang and are ignored. The following template:</p>
315
+
316
+ <pre><code>&lt;h1&gt;Today{{! ignore me }}.&lt;/h1&gt;
317
+ </code></pre>
318
+
319
+ <p>Will render as follows:</p>
320
+
321
+ <pre><code>&lt;h1&gt;Today.&lt;/h1&gt;
322
+ </code></pre>
323
+
324
+ <p>Comments may contain newlines.</p>
325
+
326
+ <h3>Partials</h3>
327
+
328
+ <p>Partials begin with a greater than sign, like <code>{{&gt; box}}</code>.</p>
329
+
330
+ <p>Partials are rendered at runtime (as opposed to compile time), so
331
+ recursive partials are possible. Just avoid infinite loops.</p>
332
+
333
+ <p>They also inherit the calling context. Whereas in ERB you may have
334
+ this:</p>
335
+
336
+ <pre><code>&lt;%= partial :next_more, :start =&gt; start, :size =&gt; size %&gt;
337
+ </code></pre>
338
+
339
+ <p>Mustache requires only this:</p>
340
+
341
+ <pre><code>{{&gt; next_more}}
342
+ </code></pre>
343
+
344
+ <p>Why? Because the <code>next_more.mustache</code> file will inherit the <code>size</code> and
345
+ <code>start</code> methods from the calling context.</p>
346
+
347
+ <p>In this way you may want to think of partials as includes, or template
348
+ expansion, even though it's not literally true.</p>
349
+
350
+ <p>For example, this template and partial:</p>
351
+
352
+ <pre><code>base.mustache:
353
+ &lt;h2&gt;Names&lt;/h2&gt;
354
+ {{#names}}
355
+ {{&gt; user}}
356
+ {{/names}}
357
+
358
+ user.mustache:
359
+ &lt;strong&gt;{{name}}&lt;/strong&gt;
360
+ </code></pre>
361
+
362
+ <p>Can be thought of as a single, expanded template:</p>
363
+
364
+ <pre><code>&lt;h2&gt;Names&lt;/h2&gt;
365
+ {{#names}}
366
+ &lt;strong&gt;{{name}}&lt;/strong&gt;
367
+ {{/names}}
368
+ </code></pre>
369
+
370
+ <h3>Set Delimiter</h3>
371
+
372
+ <p>Set Delimiter tags start with an equal sign and change the tag
373
+ delimiters from <code>{{</code> and <code>}}</code> to custom strings.</p>
374
+
375
+ <p>Consider the following contrived example:</p>
376
+
377
+ <pre><code>* {{default_tags}}
378
+ {{=&lt;% %>=}}
379
+ * &lt;% erb_style_tags %>
380
+ &lt;%={{ }}=%>
381
+ * {{ default_tags_again }}
382
+ </code></pre>
383
+
384
+ <p>Here we have a list with three items. The first item uses the default
385
+ tag style, the second uses erb style as defined by the Set Delimiter
386
+ tag, and the third returns to the default style after yet another Set
387
+ Delimiter declaration.</p>
388
+
389
+ <p>According to <a href="http://google-ctemplate.googlecode.com/svn/trunk/doc/howto.html">ctemplates</a>, this "is useful for languages like TeX, where
390
+ double-braces may occur in the text and are awkward to use for
391
+ markup."</p>
392
+
393
+ <p>Custom delimiters may not contain whitespace or the equals sign.</p>
394
+
395
+ <h2>COPYRIGHT</h2>
396
+
397
+ <p>Mustache is Copyright (C) 2009 Chris Wanstrath</p>
398
+
399
+ <p>Original CTemplate by Google</p>
400
+
401
+ <h2>SEE ALSO</h2>
402
+
403
+ <p>mustache(1), mustache(7),
404
+ <a href="http://mustache.github.com/">http://mustache.github.com/</a></p>
405
+
406
+
407
+ <ol class='foot man'>
408
+ <li class='tl'>DEFUNKT</li>
409
+ <li class='tc'>May 2010</li>
410
+ <li class='tr'>mustache(5)</li>
411
+ </ol>
412
+
413
+ </div>
414
+ </body>
415
+ </html>
@@ -0,0 +1,324 @@
1
+ mustache(5) -- Logic-less templates.
2
+ ====================================
3
+
4
+ ## SYNOPSIS
5
+
6
+ A typical Mustache template:
7
+
8
+ Hello {{name}}
9
+ You have just won {{value}} dollars!
10
+ {{#in_ca}}
11
+ Well, {{taxed_value}} dollars, after taxes.
12
+ {{/in_ca}}
13
+
14
+ Given the following hash:
15
+
16
+ {
17
+ "name": "Chris",
18
+ "value": 10000,
19
+ "taxed_value": 10000 - (10000 * 0.4),
20
+ "in_ca": true
21
+ }
22
+
23
+ Will produce the following:
24
+
25
+ Hello Chris
26
+ You have just won 10000 dollars!
27
+ Well, 6000.0 dollars, after taxes.
28
+
29
+
30
+ ## DESCRIPTION
31
+
32
+ Mustache can be used for HTML, config files, source code -
33
+ anything. It works by expanding tags in a template using values
34
+ provided in a hash or object.
35
+
36
+ We call it "logic-less" because there are no if statements, else
37
+ clauses, or for loops. Instead there are only tags. Some tags are
38
+ replaced with a value, some nothing, and others a series of
39
+ values. This document explains the different types of Mustache tags.
40
+
41
+
42
+ ## TAG TYPES
43
+
44
+ Tags are indicated by the double mustaches. `{{person}}` is a tag, as
45
+ is `{{#person}}`. In both examples, we'd refer to `person` as the key
46
+ or tag key. Let's talk about the different types of tags.
47
+
48
+
49
+ ### Variables
50
+
51
+ The most basic tag type is the variable. A `{{name}}` tag in a basic
52
+ template will try to find the `name` key in the current context. If
53
+ there is no `name` key, nothing will be rendered.
54
+
55
+ All variables are HTML escaped by default. If you want to return
56
+ unescaped HTML, use the triple mustache: `{{{name}}}`.
57
+
58
+ You can also use `&` to unescape a variable: `{{& name}}`. This may be
59
+ useful when changing delimiters (see "Set Delimiter" below).
60
+
61
+ By default a variable "miss" returns an empty string. This can usually
62
+ be configured in your Mustache library. The Ruby version of Mustache
63
+ supports raising an exception in this situation, for instance.
64
+
65
+ Template:
66
+
67
+ * {{name}}
68
+ * {{age}}
69
+ * {{company}}
70
+ * {{{company}}}
71
+
72
+ Hash:
73
+
74
+ {
75
+ "name": "Chris",
76
+ "company": "<b>GitHub</b>"
77
+ }
78
+
79
+ Output:
80
+
81
+ * Chris
82
+ *
83
+ * &lt;b&gt;GitHub&lt;/b&gt;
84
+ * <b>GitHub</b>
85
+
86
+
87
+ ### Sections
88
+
89
+ Sections render blocks of text one or more times, depending on the
90
+ value of the key in the current context.
91
+
92
+ A section begins with a pound and ends with a slash. That is,
93
+ `{{#person}}` begins a "person" section while `{{/person}}` ends it.
94
+
95
+ The behavior of the section is determined by the value of the key.
96
+
97
+ **False Values or Empty Lists**
98
+
99
+ If the `person` key exists and has a value of false or an empty
100
+ list, the HTML between the pound and slash will not be displayed.
101
+
102
+ Template:
103
+
104
+ Shown.
105
+ {{#nothin}}
106
+ Never shown!
107
+ {{/nothin}}
108
+
109
+ Hash:
110
+
111
+ {
112
+ "person": true,
113
+ }
114
+
115
+ Output:
116
+
117
+ Shown.
118
+
119
+ **Non-Empty Lists**
120
+
121
+ If the `person` key exists and has a non-false value, the HTML between
122
+ the pound and slash will be rendered and displayed one or more times.
123
+
124
+ When the value is a non-empty list, the text in the block will be
125
+ displayed once for each item in the list. The context of the block
126
+ will be set to the current item for each iteration. In this way we can
127
+ loop over collections.
128
+
129
+ Template:
130
+
131
+ {{#repo}}
132
+ <b>{{name}}</b>
133
+ {{/repo}}
134
+
135
+ Hash:
136
+
137
+ {
138
+ "repo": [
139
+ { "name": "resque" },
140
+ { "name": "hub" },
141
+ { "name": "rip" },
142
+ ]
143
+ }
144
+
145
+ Output:
146
+
147
+ <b>resque</b>
148
+ <b>hub</b>
149
+ <b>rip</b>
150
+
151
+ **Lambdas**
152
+
153
+ When the value is a callable object, such as a function or lambda, the
154
+ object will be invoked and passed the block of text. The text passed
155
+ is the literal block, unrendered. `{{tags}}` will not have been expanded
156
+ - the lambda should do that on its own. In this way you can implement
157
+ filters or caching.
158
+
159
+ Template:
160
+
161
+ {{#wrapped}}
162
+ {{name}} is awesome.
163
+ {{/wrapped}}
164
+
165
+ Hash:
166
+
167
+ {
168
+ "name": "Willy",
169
+ "wrapped": function() {
170
+ return function(text) {
171
+ return "<b>" + render(text) + "</b>"
172
+ }
173
+ }
174
+ }
175
+
176
+ Output:
177
+
178
+ <b>Willy is awesome.</b>
179
+
180
+ **Non-False Values**
181
+
182
+ When the value is non-false but not a list, it will be used as the
183
+ context for a single rendering of the block.
184
+
185
+ Template:
186
+
187
+ {{#person?}}
188
+ Hi {{name}}!
189
+ {{/person?}}
190
+
191
+ Hash:
192
+
193
+ {
194
+ "person?": { "name": "Jon" }
195
+ }
196
+
197
+ Output:
198
+
199
+ Hi Jon!
200
+
201
+
202
+ ### Inverted Sections
203
+
204
+ An inverted section begins with a caret (hat) and ends with a
205
+ slash. That is `{{^person}}` begins a "person" inverted section while
206
+ `{{/person}}` ends it.
207
+
208
+ While sections can be used to render text one or more times based on the
209
+ value of the key, inverted sections may render text once based
210
+ on the inverse value of the key. That is, they will be rendered
211
+ if the key doesn't exist, is false, or is an empty list.
212
+
213
+ Template:
214
+
215
+ {{#repo}}
216
+ <b>{{name}}</b>
217
+ {{/repo}}
218
+ {{^repo}}
219
+ No repos :(
220
+ {{/repo}}
221
+
222
+ Hash:
223
+
224
+ {
225
+ "repo": []
226
+ }
227
+
228
+ Output:
229
+
230
+ No repos :(
231
+
232
+
233
+ ### Comments
234
+
235
+ Comments begin with a bang and are ignored. The following template:
236
+
237
+ <h1>Today{{! ignore me }}.</h1>
238
+
239
+ Will render as follows:
240
+
241
+ <h1>Today.</h1>
242
+
243
+ Comments may contain newlines.
244
+
245
+
246
+ ### Partials
247
+
248
+ Partials begin with a greater than sign, like `{{> box}}`.
249
+
250
+ Partials are rendered at runtime (as opposed to compile time), so
251
+ recursive partials are possible. Just avoid infinite loops.
252
+
253
+ They also inherit the calling context. Whereas in ERB you may have
254
+ this:
255
+
256
+ <%= partial :next_more, :start => start, :size => size %>
257
+
258
+ Mustache requires only this:
259
+
260
+ {{> next_more}}
261
+
262
+ Why? Because the `next_more.mustache` file will inherit the `size` and
263
+ `start` methods from the calling context.
264
+
265
+ In this way you may want to think of partials as includes, or template
266
+ expansion, even though it's not literally true.
267
+
268
+ For example, this template and partial:
269
+
270
+ base.mustache:
271
+ <h2>Names</h2>
272
+ {{#names}}
273
+ {{> user}}
274
+ {{/names}}
275
+
276
+ user.mustache:
277
+ <strong>{{name}}</strong>
278
+
279
+ Can be thought of as a single, expanded template:
280
+
281
+ <h2>Names</h2>
282
+ {{#names}}
283
+ <strong>{{name}}</strong>
284
+ {{/names}}
285
+
286
+
287
+ ### Set Delimiter
288
+
289
+ Set Delimiter tags start with an equal sign and change the tag
290
+ delimiters from `{{` and `}}` to custom strings.
291
+
292
+ Consider the following contrived example:
293
+
294
+ * {{default_tags}}
295
+ {{=<% %>=}}
296
+ * <% erb_style_tags %>
297
+ <%={{ }}=%>
298
+ * {{ default_tags_again }}
299
+
300
+ Here we have a list with three items. The first item uses the default
301
+ tag style, the second uses erb style as defined by the Set Delimiter
302
+ tag, and the third returns to the default style after yet another Set
303
+ Delimiter declaration.
304
+
305
+ According to [ctemplates][ct], this "is useful for languages like TeX, where
306
+ double-braces may occur in the text and are awkward to use for
307
+ markup."
308
+
309
+ Custom delimiters may not contain whitespace or the equals sign.
310
+
311
+ [ct]: http://google-ctemplate.googlecode.com/svn/trunk/doc/howto.html
312
+
313
+
314
+ ## COPYRIGHT
315
+
316
+ Mustache is Copyright (C) 2009 Chris Wanstrath
317
+
318
+ Original CTemplate by Google
319
+
320
+
321
+ ## SEE ALSO
322
+
323
+ mustache(1), mustache(7),
324
+ <http://mustache.github.com/>