mustache 0.99.4 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +183 -183
  3. data/Rakefile +6 -14
  4. data/bin/mustache +28 -14
  5. data/lib/mustache/context.rb +98 -46
  6. data/lib/mustache/context_miss.rb +55 -0
  7. data/lib/mustache/enumerable.rb +3 -0
  8. data/lib/mustache/generator.rb +63 -42
  9. data/lib/mustache/parser.rb +173 -65
  10. data/lib/mustache/settings.rb +84 -24
  11. data/lib/mustache/template.rb +74 -4
  12. data/lib/mustache/utils.rb +31 -0
  13. data/lib/mustache/version.rb +1 -1
  14. data/lib/mustache.rb +116 -96
  15. data/man/mustache.1 +25 -40
  16. data/man/mustache.1.html +90 -81
  17. data/man/mustache.1.ron +6 -6
  18. data/man/mustache.5 +338 -298
  19. data/man/mustache.5.html +400 -115
  20. data/man/mustache.5.ron +292 -32
  21. data/test/autoloading_test.rb +7 -3
  22. data/test/fixtures/comments.rb +0 -1
  23. data/test/fixtures/complex_view.rb +0 -1
  24. data/test/fixtures/crazy_recursive.rb +0 -1
  25. data/test/fixtures/delimiters.rb +0 -1
  26. data/test/fixtures/dot_notation.rb +0 -1
  27. data/test/fixtures/double_section.rb +0 -1
  28. data/test/fixtures/inverted_section.rb +0 -1
  29. data/test/fixtures/lambda.rb +0 -1
  30. data/test/fixtures/liberal.mustache +1 -0
  31. data/test/fixtures/liberal.rb +25 -0
  32. data/test/fixtures/method_missing.rb +0 -1
  33. data/test/fixtures/namespaced.rb +0 -1
  34. data/test/fixtures/nested_objects.rb +0 -1
  35. data/test/fixtures/override/passenger.conf +6 -0
  36. data/test/fixtures/partial_with_module.rb +0 -1
  37. data/test/fixtures/passenger.rb +0 -1
  38. data/test/fixtures/recursive.rb +0 -1
  39. data/test/fixtures/simple.rb +0 -1
  40. data/test/fixtures/simply_complicated.mustache +25 -0
  41. data/test/fixtures/template_partial.rb +0 -1
  42. data/test/fixtures/unescaped.rb +0 -1
  43. data/test/helper.rb +5 -2
  44. data/test/mustache_test.rb +210 -25
  45. data/test/parser_test.rb +90 -7
  46. data/test/partial_test.rb +16 -4
  47. data/test/path_test.rb +49 -0
  48. data/test/spec_test.rb +5 -5
  49. data/test/template_test.rb +35 -3
  50. metadata +37 -59
  51. data/lib/mustache/sinatra.rb +0 -186
  52. data/lib/rack/bug/panels/mustache_panel/mustache_extension.rb +0 -27
  53. data/lib/rack/bug/panels/mustache_panel/view.mustache +0 -46
  54. data/lib/rack/bug/panels/mustache_panel.rb +0 -81
data/man/mustache.5.html CHANGED
@@ -1,71 +1,79 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
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 }
4
+ <meta http-equiv='content-type' content='text/html;charset=utf8'>
5
+ <meta name='generator' content='Ronn-NG/v0.9.1 (http://github.com/apjanke/ronn-ng/tree/0.9.1)'>
6
+ <title>mustache(5) - Logic-less templates.</title>
7
+ <style type='text/css' media='all'>
8
+ /* style: man */
9
+ body#manpage {margin:0}
10
+ .mp {max-width:100ex;padding:0 9ex 1ex 4ex}
11
+ .mp p,.mp pre,.mp ul,.mp ol,.mp dl {margin:0 0 20px 0}
12
+ .mp h2 {margin:10px 0 0 0}
13
+ .mp > p,.mp > pre,.mp > ul,.mp > ol,.mp > dl {margin-left:8ex}
14
+ .mp h3 {margin:0 0 0 4ex}
15
+ .mp dt {margin:0;clear:left}
16
+ .mp dt.flush {float:left;width:8ex}
17
+ .mp dd {margin:0 0 0 9ex}
18
+ .mp h1,.mp h2,.mp h3,.mp h4 {clear:left}
19
+ .mp pre {margin-bottom:20px}
20
+ .mp pre+h2,.mp pre+h3 {margin-top:22px}
21
+ .mp h2+pre,.mp h3+pre {margin-top:5px}
22
+ .mp img {display:block;margin:auto}
23
+ .mp h1.man-title {display:none}
24
+ .mp,.mp code,.mp pre,.mp tt,.mp kbd,.mp samp,.mp h3,.mp h4 {font-family:monospace;font-size:14px;line-height:1.42857142857143}
25
+ .mp h2 {font-size:16px;line-height:1.25}
26
+ .mp h1 {font-size:20px;line-height:2}
27
+ .mp {text-align:justify;background:#fff}
28
+ .mp,.mp code,.mp pre,.mp pre code,.mp tt,.mp kbd,.mp samp {color:#131211}
29
+ .mp h1,.mp h2,.mp h3,.mp h4 {color:#030201}
30
+ .mp u {text-decoration:underline}
31
+ .mp code,.mp strong,.mp b {font-weight:bold;color:#131211}
32
+ .mp em,.mp var {font-style:italic;color:#232221;text-decoration:none}
33
+ .mp a,.mp a:link,.mp a:hover,.mp a code,.mp a pre,.mp a tt,.mp a kbd,.mp a samp {color:#0000ff}
34
+ .mp b.man-ref {font-weight:normal;color:#434241}
35
+ .mp pre {padding:0 4ex}
36
+ .mp pre code {font-weight:normal;color:#434241}
37
+ .mp h2+pre,h3+pre {padding-left:0}
38
+ ol.man-decor,ol.man-decor li {margin:3px 0 10px 0;padding:0;float:left;width:33%;list-style-type:none;text-transform:uppercase;color:#999;letter-spacing:1px}
39
+ ol.man-decor {width:100%}
40
+ ol.man-decor li.tl {text-align:left}
41
+ ol.man-decor li.tc {text-align:center;letter-spacing:4px}
42
+ ol.man-decor li.tr {text-align:right;float:right}
52
43
  </style>
53
44
  </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>
45
+ <!--
46
+ The following styles are deprecated and will be removed at some point:
47
+ div#man, div#man ol.man, div#man ol.head, div#man ol.man.
48
+
49
+ The .man-page, .man-decor, .man-head, .man-foot, .man-title, and
50
+ .man-navigation should be used instead.
51
+ -->
52
+ <body id='manpage'>
53
+ <div class='mp' id='man'>
54
+
55
+ <div class='man-navigation' style='display:none'>
56
+ <a href="#NAME">NAME</a>
57
+ <a href="#SYNOPSIS">SYNOPSIS</a>
58
+ <a href="#DESCRIPTION">DESCRIPTION</a>
59
+ <a href="#TAG-TYPES">TAG TYPES</a>
60
+ <a href="#COPYRIGHT">COPYRIGHT</a>
61
+ <a href="#SEE-ALSO">SEE ALSO</a>
62
+ </div>
63
+
64
+ <ol class='man-decor man-head man head'>
65
+ <li class='tl'>mustache(5)</li>
66
+ <li class='tc'>Mustache Manual</li>
67
+ <li class='tr'>mustache(5)</li>
68
+ </ol>
69
+
70
+
71
+
72
+ <h2 id="NAME">NAME</h2>
73
+ <p class="man-name">
74
+ <code>mustache</code> - <span class="man-whatis">Logic-less templates.</span>
75
+ </p>
76
+ <h2 id="SYNOPSIS">SYNOPSIS</h2>
69
77
 
70
78
  <p>A typical Mustache template:</p>
71
79
 
@@ -93,7 +101,7 @@ You have just won 10000 dollars!
93
101
  Well, 6000.0 dollars, after taxes.
94
102
  </code></pre>
95
103
 
96
- <h2>DESCRIPTION</h2>
104
+ <h2 id="DESCRIPTION">DESCRIPTION</h2>
97
105
 
98
106
  <p>Mustache can be used for HTML, config files, source code -
99
107
  anything. It works by expanding tags in a template using values
@@ -104,22 +112,28 @@ clauses, or for loops. Instead there are only tags. Some tags are
104
112
  replaced with a value, some nothing, and others a series of
105
113
  values. This document explains the different types of Mustache tags.</p>
106
114
 
107
- <h2>TAG TYPES</h2>
115
+ <p>The Mustache language has a <a href="https://github.com/mustache/spec">formal specification</a>. The current
116
+ manpage reflects version 1.3.0 of the specification, including the
117
+ official-but-optional extensions for lambdas and inheritance.</p>
118
+
119
+ <h2 id="TAG-TYPES">TAG TYPES</h2>
108
120
 
109
121
  <p>Tags are indicated by the double mustaches. <code>{{person}}</code> is a tag, as
110
122
  is <code>{{#person}}</code>. In both examples, we'd refer to <code>person</code> as the key
111
123
  or tag key. Let's talk about the different types of tags.</p>
112
124
 
113
- <h3>Variables</h3>
125
+ <h3 id="Variables">Variables</h3>
114
126
 
115
127
  <p>The most basic tag type is the variable. A <code>{{name}}</code> tag in a basic
116
128
  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>
129
+ there is no <code>name</code> key, the parent contexts will be checked recursively.
130
+ If the top context is reached and the <code>name</code> key is still not found,
131
+ nothing will be rendered.</p>
118
132
 
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>
133
+ <p>All variables are HTML escaped by default. If you want to return raw contents
134
+ without escaping, use the triple mustache: <code>{{{name}}}</code>.</p>
121
135
 
122
- <p>You can also use <code>&amp;</code> to unescape a variable: <code>{{&amp; name}}</code>. This may be
136
+ <p>You can also use <code>&amp;</code> to return its raw contents: <code>{{&amp; name}}</code>. This may be
123
137
  useful when changing delimiters (see "Set Delimiter" below).</p>
124
138
 
125
139
  <p>By default a variable "miss" returns an empty string. This can usually
@@ -150,15 +164,121 @@ supports raising an exception in this situation, for instance.</p>
150
164
  * &lt;b&gt;GitHub&lt;/b&gt;
151
165
  </code></pre>
152
166
 
153
- <h3>Sections</h3>
167
+ <p><strong>Dotted Names</strong></p>
168
+
169
+ <p>If the <code>name</code> contains dots, it is split on the dots to obtain multiple
170
+ keys. The first key is looked up in the context as described above. If it
171
+ is found, the next key is looked up within the previous result. This is
172
+ repeated until a key is not found or until the last key is found. The
173
+ final result is interpolated as above.</p>
174
+
175
+ <p>Template:</p>
154
176
 
155
- <p>Sections render blocks of text one or more times, depending on the
177
+ <pre><code>* {{client.name}}
178
+ * {{age}}
179
+ * {{client.company.name}}
180
+ * {{{company.name}}}
181
+ </code></pre>
182
+
183
+ <p>Hash:</p>
184
+
185
+ <pre><code>{
186
+ "client": {
187
+ "name": "Chris &amp; Friends",
188
+ "age": 50
189
+ },
190
+ "company": {
191
+ "name": "&lt;b&gt;GitHub&lt;/b&gt;"
192
+ }
193
+ }
194
+ </code></pre>
195
+
196
+ <p>Output:</p>
197
+
198
+ <pre><code>* Chris &amp;amp; Friends
199
+ *
200
+ *
201
+ * &lt;b&gt;GitHub&lt;/b&gt;
202
+ </code></pre>
203
+
204
+ <p><strong>Implicit Iterator</strong></p>
205
+
206
+ <p>As a special case, if the <code>name</code> consists of only a dot and nothing else,
207
+ the value that is the current context is interpolated as a whole. This
208
+ is especially useful if the parent context is a list; see <strong>Sections</strong>
209
+ below.</p>
210
+
211
+ <p>Template:</p>
212
+
213
+ <pre><code>* {{.}}
214
+ </code></pre>
215
+
216
+ <p>Current context:</p>
217
+
218
+ <pre><code>"Hello!"
219
+ </code></pre>
220
+
221
+ <p>Output:</p>
222
+
223
+ <pre><code>* Hello!
224
+ </code></pre>
225
+
226
+ <p><strong>Lambdas</strong></p>
227
+
228
+ <p>If any value found during the lookup is a callable object, such as a
229
+ function or lambda, this object will be invoked with zero arguments. The
230
+ value that is returned is then used instead of the callable object itself.</p>
231
+
232
+ <p>An <strong>optional</strong> part of the specification states that if the final key in
233
+ the <code>name</code> is a lambda that returns a string, then that string should be
234
+ rendered as a Mustache template before interpolation. It will be rendered
235
+ using the default delimiters (see <strong>Set Delimiter</strong> below) against the
236
+ current context.</p>
237
+
238
+ <p>Template:</p>
239
+
240
+ <pre><code>* {{time.hour}}
241
+ * {{today}}
242
+ </code></pre>
243
+
244
+ <p>Hash:</p>
245
+
246
+ <pre><code>{
247
+ "year": 1970,
248
+ "month": 1,
249
+ "day": 1,
250
+ "time": function() {
251
+ return {
252
+ "hour": 0,
253
+ "minute": 0,
254
+ "second": 0
255
+ }
256
+ },
257
+ "today": function() {
258
+ return "{{year}}-{{month}}-{{day}}"
259
+ }
260
+ }
261
+ </code></pre>
262
+
263
+ <p>Output:</p>
264
+
265
+ <pre><code>* 0
266
+ * 1970-1-1
267
+ </code></pre>
268
+
269
+ <h3 id="Sections">Sections</h3>
270
+
271
+ <p>Sections render blocks of text zero or more times, depending on the
156
272
  value of the key in the current context.</p>
157
273
 
274
+ <p>Lookup of dotted names works in the same way as with variables, except for
275
+ slightly different treatment of lambdas. More on this below.</p>
276
+
158
277
  <p>A section begins with a pound and ends with a slash. That is,
159
278
  <code>{{#person}}</code> begins a "person" section while <code>{{/person}}</code> ends it.</p>
160
279
 
161
- <p>The behavior of the section is determined by the value of the key.</p>
280
+ <p>The behavior of the section is determined by the final value of the key
281
+ lookup.</p>
162
282
 
163
283
  <p><strong>False Values or Empty Lists</strong></p>
164
284
 
@@ -168,15 +288,15 @@ list, the HTML between the pound and slash will not be displayed.</p>
168
288
  <p>Template:</p>
169
289
 
170
290
  <pre><code>Shown.
171
- {{#nothin}}
291
+ {{#person}}
172
292
  Never shown!
173
- {{/nothin}}
293
+ {{/person}}
174
294
  </code></pre>
175
295
 
176
296
  <p>Hash:</p>
177
297
 
178
298
  <pre><code>{
179
- "person": true,
299
+ "person": false
180
300
  }
181
301
  </code></pre>
182
302
 
@@ -187,7 +307,7 @@ list, the HTML between the pound and slash will not be displayed.</p>
187
307
 
188
308
  <p><strong>Non-Empty Lists</strong></p>
189
309
 
190
- <p>If the <code>person</code> key exists and has a non-false value, the HTML between
310
+ <p>If the <code>repo</code> key exists and has a non-false value, the HTML between
191
311
  the pound and slash will be rendered and displayed one or more times.</p>
192
312
 
193
313
  <p>When the value is a non-empty list, the text in the block will be
@@ -208,41 +328,66 @@ loop over collections.</p>
208
328
  "repo": [
209
329
  { "name": "resque" },
210
330
  { "name": "hub" },
211
- { "name": "rip" },
331
+ { "name": "rip" }
212
332
  ]
213
333
  }
214
334
  </code></pre>
215
335
 
216
336
  <p>Output:</p>
217
337
 
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;
338
+ <pre><code> &lt;b&gt;resque&lt;/b&gt;
339
+ &lt;b&gt;hub&lt;/b&gt;
340
+ &lt;b&gt;rip&lt;/b&gt;
341
+ </code></pre>
342
+
343
+ <p>The same effect as above can be obtained without nested objects, by using
344
+ the implicit iterator (see <strong>Variables</strong> above).</p>
345
+
346
+ <p>Template:</p>
347
+
348
+ <pre><code>{{#repo}}
349
+ &lt;b&gt;{{.}}&lt;/b&gt;
350
+ {{/repo}}
351
+ </code></pre>
352
+
353
+ <p>Hash:</p>
354
+
355
+ <pre><code>{
356
+ "repo": ["resque", "hub", "rip"]
357
+ }
358
+ </code></pre>
359
+
360
+ <p>Output:</p>
361
+
362
+ <pre><code> &lt;b&gt;resque&lt;/b&gt;
363
+ &lt;b&gt;hub&lt;/b&gt;
364
+ &lt;b&gt;rip&lt;/b&gt;
221
365
  </code></pre>
222
366
 
223
367
  <p><strong>Lambdas</strong></p>
224
368
 
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>
369
+ <p>When any value found during the lookup is a callable object, such as a
370
+ function or lambda, the object will be invoked and passed the block of
371
+ text. The text passed is the literal block, unrendered. <code>{{tags}}</code> will
372
+ not have been expanded.</p>
373
+
374
+ <p>An <strong>optional</strong> part of the specification states that if the final key in
375
+ the <code>name</code> is a lambda that returns a string, then that string replaces
376
+ the content of the section. It will be rendered using the same delimiters
377
+ (see <strong>Set Delimiter</strong> below) as the original section content. In this way
378
+ you can implement filters or caching.</p>
230
379
 
231
380
  <p>Template:</p>
232
381
 
233
- <pre><code>{{#wrapped}}
234
- {{name}} is awesome.
235
- {{/wrapped}}
382
+ <pre><code>{{#wrapped}}{{name}} is awesome.{{/wrapped}}
236
383
  </code></pre>
237
384
 
238
385
  <p>Hash:</p>
239
386
 
240
387
  <pre><code>{
241
388
  "name": "Willy",
242
- "wrapped": function() {
243
- return function(text) {
244
- return "&lt;b&gt;" + render(text) + "&lt;/b&gt;"
245
- }
389
+ "wrapped": function(text) {
390
+ return "&lt;b&gt;" + text + "&lt;/b&gt;"
246
391
  }
247
392
  }
248
393
  </code></pre>
@@ -273,16 +418,16 @@ context for a single rendering of the block.</p>
273
418
 
274
419
  <p>Output:</p>
275
420
 
276
- <pre><code>Hi Jon!
421
+ <pre><code> Hi Jon!
277
422
  </code></pre>
278
423
 
279
- <h3>Inverted Sections</h3>
424
+ <h3 id="Inverted-Sections">Inverted Sections</h3>
280
425
 
281
426
  <p>An inverted section begins with a caret (hat) and ends with a
282
427
  slash. That is <code>{{^person}}</code> begins a "person" inverted section while
283
428
  <code>{{/person}}</code> ends it.</p>
284
429
 
285
- <p>While sections can be used to render text one or more times based on the
430
+ <p>While sections can be used to render text zero or more times based on the
286
431
  value of the key, inverted sections may render text once based
287
432
  on the inverse value of the key. That is, they will be rendered
288
433
  if the key doesn't exist, is false, or is an empty list.</p>
@@ -306,10 +451,10 @@ if the key doesn't exist, is false, or is an empty list.</p>
306
451
 
307
452
  <p>Output:</p>
308
453
 
309
- <pre><code>No repos :(
454
+ <pre><code> No repos :(
310
455
  </code></pre>
311
456
 
312
- <h3>Comments</h3>
457
+ <h3 id="Comments">Comments</h3>
313
458
 
314
459
  <p>Comments begin with a bang and are ignored. The following template:</p>
315
460
 
@@ -323,7 +468,7 @@ if the key doesn't exist, is false, or is an empty list.</p>
323
468
 
324
469
  <p>Comments may contain newlines.</p>
325
470
 
326
- <h3>Partials</h3>
471
+ <h3 id="Partials">Partials</h3>
327
472
 
328
473
  <p>Partials begin with a greater than sign, like <code>{{&gt; box}}</code>.</p>
329
474
 
@@ -367,7 +512,148 @@ user.mustache:
367
512
  {{/names}}
368
513
  </code></pre>
369
514
 
370
- <h3>Set Delimiter</h3>
515
+ <p><strong>Dynamic Names</strong></p>
516
+
517
+ <p>Partials can be loaded dynamically at runtime using Dynamic Names; an
518
+ <strong>optional</strong> part of the Mustache specification which allows to dynamically
519
+ determine a tag's content at runtime.</p>
520
+
521
+ <p>Dynamic Names consists of an asterisk, followed by a dotted name which follows
522
+ the same notation and the same resolution as in an variable tag. That is
523
+ <code>{{&gt;*dynamic}}</code>. It can be thought as the following <strong>hypothetical</strong> tag
524
+ (which is <strong>not allowed</strong>!): <code>{{&gt;{{dynamic}}}}</code>.</p>
525
+
526
+ <p>Templates:</p>
527
+
528
+ <pre><code>main.mustache:
529
+ Hello {{&gt;*dynamic}}
530
+
531
+ world.template:
532
+ everyone!
533
+ </code></pre>
534
+
535
+ <p>Hash:</p>
536
+
537
+ <pre><code>{
538
+ "dynamic": "world"
539
+ }
540
+ </code></pre>
541
+
542
+ <p>Output:</p>
543
+
544
+ <pre><code>Hello everyone!
545
+ </code></pre>
546
+
547
+ <h3 id="Blocks">Blocks</h3>
548
+
549
+ <p>A block begins with a dollar and ends with a slash. That is, <code>{{$title}}</code>
550
+ begins a "title" block and <code>{{/title}}</code> ends it.</p>
551
+
552
+ <p>Blocks mark parts of the template that may be overridden. This can be done
553
+ with a block of the same name within a parent section in the calling
554
+ template (see <strong>Parents</strong> below). If not overridden, the contents of a
555
+ block render just as if the <code>{{$title}}</code> and <code>{{/title}}</code> tags weren't
556
+ there.</p>
557
+
558
+ <p>Blocks could be thought of as template parameters or as inline partials
559
+ that may be passed to another template. They are part of the optional
560
+ inheritance extension.</p>
561
+
562
+ <p>Template <code>article.mustache</code>:</p>
563
+
564
+ <pre><code>&lt;h1&gt;{{$title}}The News of Today{{/title}}&lt;/h1&gt;
565
+ {{$body}}
566
+ &lt;p&gt;Nothing special happened.&lt;/p&gt;
567
+ {{/body}}
568
+ </code></pre>
569
+
570
+ <p>Output:</p>
571
+
572
+ <pre><code>&lt;h1&gt;The News of Today&lt;/h1&gt;
573
+ &lt;p&gt;Nothing special happened.&lt;/p&gt;
574
+ </code></pre>
575
+
576
+ <h3 id="Parents">Parents</h3>
577
+
578
+ <p>A parent begins with a less than sign and ends with a slash. That is,
579
+ <code>{{&lt;article}}</code> begins an "article" parent and <code>{{/article}}</code> ends it.</p>
580
+
581
+ <p>Like an <code>{{&gt;article}}</code> partial, a parent lets you expand another template
582
+ inside the current one. Unlike a partial, a parent also lets you override
583
+ blocks of the other template.</p>
584
+
585
+ <p>Blocks within a parent can again be overridden by another including
586
+ template. Other content within a parent is ignored, like comments.</p>
587
+
588
+ <p>Template:</p>
589
+
590
+ <pre><code>{{&lt;article}}
591
+ Never shown
592
+ {{$body}}
593
+ {{#headlines}}
594
+ &lt;p&gt;{{.}}&lt;/p&gt;
595
+ {{/headlines}}
596
+ {{/body}}
597
+ {{/article}}
598
+
599
+ {{&lt;article}}
600
+ {{$title}}Yesterday{{/title}}
601
+ {{/article}}
602
+ </code></pre>
603
+
604
+ <p>Hash:</p>
605
+
606
+ <pre><code>{
607
+ "headlines": [
608
+ "A pug's handler grew mustaches.",
609
+ "What an exciting day!"
610
+ ]
611
+ }
612
+ </code></pre>
613
+
614
+ <p>Output, assuming the <code>article.mustache</code> from before:</p>
615
+
616
+ <pre><code>&lt;h1&gt;The News of Today&lt;/h1&gt;
617
+ &lt;p&gt;A pug's handler grew mustaches.&lt;/p&gt;
618
+ &lt;p&gt;What an exciting day!&lt;/p&gt;
619
+
620
+ &lt;h1&gt;Yesterday&lt;/h1&gt;
621
+ &lt;p&gt;Nothing special happened.&lt;/p&gt;
622
+ </code></pre>
623
+
624
+ <p><strong>Dynamic Names</strong></p>
625
+
626
+ <p>Some mustache implementations may allow the use of Dynamic Names in
627
+ parent tags, similar to dynamic names in partials. Here's an example of
628
+ how Dynamic Names in parent tags work.</p>
629
+
630
+ <p>Templates:</p>
631
+
632
+ <pre><code>{{!normal.mustache}}
633
+ {{$text}}Here goes nothing.{{/text}}
634
+
635
+ {{!bold.mustache}}
636
+ &lt;b&gt;{{$text}}Here also goes nothing but it's bold.{{/text}}&lt;/b&gt;
637
+
638
+ {{!dynamic.mustache}}
639
+ {{&lt;*dynamic}}
640
+ {{$text}}Hello World!{{/text}}
641
+ {{/*dynamic}}
642
+ </code></pre>
643
+
644
+ <p>Hash:</p>
645
+
646
+ <pre><code>{
647
+ "dynamic": "bold"
648
+ }
649
+ </code></pre>
650
+
651
+ <p>Output:</p>
652
+
653
+ <pre><code>&lt;b&gt;Hello World!&lt;/b&gt;
654
+ </code></pre>
655
+
656
+ <h3 id="Set-Delimiter">Set Delimiter</h3>
371
657
 
372
658
  <p>Set Delimiter tags start with an equal sign and change the tag
373
659
  delimiters from <code>{{</code> and <code>}}</code> to custom strings.</p>
@@ -375,9 +661,9 @@ delimiters from <code>{{</code> and <code>}}</code> to custom strings.</p>
375
661
  <p>Consider the following contrived example:</p>
376
662
 
377
663
  <pre><code>* {{default_tags}}
378
- {{=&lt;% %>=}}
379
- * &lt;% erb_style_tags %>
380
- &lt;%={{ }}=%>
664
+ {{=&lt;% %&gt;=}}
665
+ * &lt;% erb_style_tags %&gt;
666
+ &lt;%={{ }}=%&gt;
381
667
  * {{ default_tags_again }}
382
668
  </code></pre>
383
669
 
@@ -386,30 +672,29 @@ tag style, the second uses erb style as defined by the Set Delimiter
386
672
  tag, and the third returns to the default style after yet another Set
387
673
  Delimiter declaration.</p>
388
674
 
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
675
+ <p>According to <a href="http://goog-ctemplate.sourceforge.net/doc/howto.html">ctemplates</a>, this "is useful for languages like TeX, where
390
676
  double-braces may occur in the text and are awkward to use for
391
677
  markup."</p>
392
678
 
393
679
  <p>Custom delimiters may not contain whitespace or the equals sign.</p>
394
680
 
395
- <h2>COPYRIGHT</h2>
681
+ <h2 id="COPYRIGHT">COPYRIGHT</h2>
396
682
 
397
683
  <p>Mustache is Copyright (C) 2009 Chris Wanstrath</p>
398
684
 
399
685
  <p>Original CTemplate by Google</p>
400
686
 
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>
687
+ <h2 id="SEE-ALSO">SEE ALSO</h2>
405
688
 
689
+ <p><a class="man-ref" href="mustache.1.ron.html">mustache<span class="s">(1)</span></a>,
690
+ <a href="http://mustache.github.io/" data-bare-link="true">http://mustache.github.io/</a></p>
406
691
 
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>
692
+ <ol class='man-decor man-foot man foot'>
693
+ <li class='tl'>DEFUNKT</li>
694
+ <li class='tc'>September 2022</li>
695
+ <li class='tr'>mustache(5)</li>
696
+ </ol>
412
697
 
413
- </div>
698
+ </div>
414
699
  </body>
415
700
  </html>