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.1.html CHANGED
@@ -2,77 +2,86 @@
2
2
  <html>
3
3
  <head>
4
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 }
5
+ <meta name='generator' value='Ronn/v0.7.3 (http://github.com/rtomayko/ronn/tree/0.7.3)'>
6
+ <title>mustache(1) - Mustache processor</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(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>
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="#OPTIONS">OPTIONS</a>
60
+ <a href="#INSTALLATION">INSTALLATION</a>
61
+ <a href="#EXAMPLES">EXAMPLES</a>
62
+ <a href="#COPYRIGHT">COPYRIGHT</a>
63
+ <a href="#SEE-ALSO">SEE ALSO</a>
64
+ </div>
65
+
66
+ <ol class='man-decor man-head man head'>
67
+ <li class='tl'>mustache(1)</li>
68
+ <li class='tc'>Mustache Manual</li>
69
+ <li class='tr'>mustache(1)</li>
70
+ </ol>
71
+
72
+ <h2 id="NAME">NAME</h2>
73
+ <p class="man-name">
74
+ <code>mustache</code> - <span class="man-whatis">Mustache processor</span>
75
+ </p>
76
+
77
+ <h2 id="SYNOPSIS">SYNOPSIS</h2>
69
78
 
70
79
  <pre><code>mustache &lt;YAML> &lt;FILE>
71
80
  mustache --compile &lt;FILE>
72
81
  mustache --tokens &lt;FILE>
73
82
  </code></pre>
74
83
 
75
- <h2>DESCRIPTION</h2>
84
+ <h2 id="DESCRIPTION">DESCRIPTION</h2>
76
85
 
77
86
  <p>Mustache is a logic-less templating system for HTML, config files,
78
87
  anything.</p>
@@ -81,7 +90,7 @@ anything.</p>
81
90
  frontmatter from standard input and prints one or more documents to
82
91
  standard output.</p>
83
92
 
84
- <p>YAML frontmatter beings with <code>---</code> on a single line, followed by YAML,
93
+ <p>YAML frontmatter begins with <code>---</code> on a single line, followed by YAML,
85
94
  ending with another <code>---</code> on a single line, e.g.</p>
86
95
 
87
96
  <pre><code>---
@@ -93,7 +102,7 @@ names: [ {name: chris}, {name: mark}, {name: scott} ]
93
102
  should work fine.</p>
94
103
 
95
104
  <p>After the frontmatter should come any valid Mustache template. See
96
- mustache(5) for an overview of Mustache templates.</p>
105
+ <a class="man-ref" href="mustache.5.ronn.html">mustache<span class="s">(5)</span></a> for an overview of Mustache templates.</p>
97
106
 
98
107
  <p>For example:</p>
99
108
 
@@ -114,7 +123,7 @@ $ cat template.mustache
114
123
  Hi {{name}}!
115
124
  {{/names}}
116
125
 
117
- $ cat data.yml template.mustache | mustache
126
+ $ mustache data.yml template.mustache
118
127
  Hi chris!
119
128
  Hi mark!
120
129
  Hi scott!
@@ -137,13 +146,13 @@ name: scott
137
146
  $ cat template.mustache
138
147
  Hi {{name}}!
139
148
 
140
- $ cat data.yml template.mustache | mustache
149
+ $ mustache data.yml template.mustache
141
150
  Hi chris!
142
151
  Hi mark!
143
152
  Hi scott!
144
153
  </code></pre>
145
154
 
146
- <h2>OPTIONS</h2>
155
+ <h2 id="OPTIONS">OPTIONS</h2>
147
156
 
148
157
  <p>By default <code>mustache</code> will try to render a Mustache template using the
149
158
  YAML frontmatter you provide. It can do a few other things, however.</p>
@@ -156,19 +165,19 @@ Mustache's internals.</p></dd>
156
165
  <dt><code>-t</code>, <code>--tokens</code></dt><dd><p>Print the tokenized form of a given Mustache template. This can be
157
166
  used to understand how Mustache parses a template. The tokens are
158
167
  handed to a generator which compiles them into a Ruby
159
- string. Syntax errors and confused tags, therefor, can probably be
168
+ string. Syntax errors and confused tags, therefore, can probably be
160
169
  identified by examining the tokens produced.</p></dd>
161
170
  </dl>
162
171
 
163
172
 
164
- <h2>INSTALLATION</h2>
173
+ <h2 id="INSTALLATION">INSTALLATION</h2>
165
174
 
166
175
  <p>If you have RubyGems installed:</p>
167
176
 
168
177
  <pre><code>gem install mustache
169
178
  </code></pre>
170
179
 
171
- <h2>EXAMPLES</h2>
180
+ <h2 id="EXAMPLES">EXAMPLES</h2>
172
181
 
173
182
  <pre><code>$ mustache data.yml template.mustache
174
183
  $ cat data.yml | mustache - template.mustache
@@ -181,24 +190,24 @@ age: 30
181
190
  data
182
191
  </code></pre>
183
192
 
184
- <h2>COPYRIGHT</h2>
193
+ <h2 id="COPYRIGHT">COPYRIGHT</h2>
185
194
 
186
195
  <p>Mustache is Copyright (C) 2009 Chris Wanstrath</p>
187
196
 
188
197
  <p>Original CTemplate by Google</p>
189
198
 
190
- <h2>SEE ALSO</h2>
199
+ <h2 id="SEE-ALSO">SEE ALSO</h2>
191
200
 
192
- <p>mustache(5), mustache(7), gem(1),
193
- <a href="http://mustache.github.com/">http://mustache.github.com/</a></p>
201
+ <p><a class="man-ref" href="mustache.5.ronn.html">mustache<span class="s">(5)</span></a>, <span class="man-ref">gem<span class="s">(1)</span></span>,
202
+ <a href="http://mustache.github.io/" data-bare-link="true">http://mustache.github.io/</a></p>
194
203
 
195
204
 
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>
205
+ <ol class='man-decor man-foot man foot'>
206
+ <li class='tl'>DEFUNKT</li>
207
+ <li class='tc'>November 2016</li>
208
+ <li class='tr'>mustache(1)</li>
209
+ </ol>
201
210
 
202
- </div>
211
+ </div>
203
212
  </body>
204
213
  </html>
data/man/mustache.1.ron CHANGED
@@ -17,7 +17,7 @@ The `mustache` command processes a Mustache template preceded by YAML
17
17
  frontmatter from standard input and prints one or more documents to
18
18
  standard output.
19
19
 
20
- YAML frontmatter beings with `---` on a single line, followed by YAML,
20
+ YAML frontmatter begins with `---` on a single line, followed by YAML,
21
21
  ending with another `---` on a single line, e.g.
22
22
 
23
23
  ---
@@ -48,7 +48,7 @@ Now let's combine them.
48
48
  Hi {{name}}!
49
49
  {{/names}}
50
50
 
51
- $ cat data.yml template.mustache | mustache
51
+ $ mustache data.yml template.mustache
52
52
  Hi chris!
53
53
  Hi mark!
54
54
  Hi scott!
@@ -70,7 +70,7 @@ For example:
70
70
  $ cat template.mustache
71
71
  Hi {{name}}!
72
72
 
73
- $ cat data.yml template.mustache | mustache
73
+ $ mustache data.yml template.mustache
74
74
  Hi chris!
75
75
  Hi mark!
76
76
  Hi scott!
@@ -90,7 +90,7 @@ YAML frontmatter you provide. It can do a few other things, however.
90
90
  Print the tokenized form of a given Mustache template. This can be
91
91
  used to understand how Mustache parses a template. The tokens are
92
92
  handed to a generator which compiles them into a Ruby
93
- string. Syntax errors and confused tags, therefor, can probably be
93
+ string. Syntax errors and confused tags, therefore, can probably be
94
94
  identified by examining the tokens produced.
95
95
 
96
96
 
@@ -123,5 +123,5 @@ Original CTemplate by Google
123
123
 
124
124
  ## SEE ALSO
125
125
 
126
- mustache(5), mustache(7), gem(1),
127
- <http://mustache.github.com/>
126
+ mustache(5), gem(1),
127
+ <http://mustache.github.io/>