Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: pkg/mustache/test/spec/interpolation.yml

Issue 804973002: Add appengine/gcloud/mustache dependencies. (Closed) Base URL: git@github.com:dart-lang/pub-dartlang-dart.git@master
Patch Set: Added AUTHORS/LICENSE/PATENTS files Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/mustache/test/spec/interpolation.json ('k') | pkg/mustache/test/spec/inverted.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 overview: |
2 Interpolation tags are used to integrate dynamic content into the template.
3
4 The tag's content MUST be a non-whitespace character sequence NOT containing
5 the current closing delimiter.
6
7 This tag's content names the data to replace the tag. A single period (`.`)
8 indicates that the item currently sitting atop the context stack should be
9 used; otherwise, name resolution is as follows:
10 1) Split the name on periods; the first part is the name to resolve, any
11 remaining parts should be retained.
12 2) Walk the context stack from top to bottom, finding the first context
13 that is a) a hash containing the name as a key OR b) an object responding
14 to a method with the given name.
15 3) If the context is a hash, the data is the value associated with the
16 name.
17 4) If the context is an object, the data is the value returned by the
18 method with the given name.
19 5) If any name parts were retained in step 1, each should be resolved
20 against a context stack containing only the result from the former
21 resolution. If any part fails resolution, the result should be considered
22 falsey, and should interpolate as the empty string.
23 Data should be coerced into a string (and escaped, if appropriate) before
24 interpolation.
25
26 The Interpolation tags MUST NOT be treated as standalone.
27 tests:
28 - name: No Interpolation
29 desc: Mustache-free templates should render as-is.
30 data: { }
31 template: |
32 Hello from {Mustache}!
33 expected: |
34 Hello from {Mustache}!
35
36 - name: Basic Interpolation
37 desc: Unadorned tags should interpolate content into the template.
38 data: { subject: "world" }
39 template: |
40 Hello, {{subject}}!
41 expected: |
42 Hello, world!
43
44 - name: HTML Escaping
45 desc: Basic interpolation should be HTML escaped.
46 data: { forbidden: '& " < >' }
47 template: |
48 These characters should be HTML escaped: {{forbidden}}
49 expected: |
50 These characters should be HTML escaped: &amp; &quot; &lt; &gt;
51
52 - name: Triple Mustache
53 desc: Triple mustaches should interpolate without HTML escaping.
54 data: { forbidden: '& " < >' }
55 template: |
56 These characters should not be HTML escaped: {{{forbidden}}}
57 expected: |
58 These characters should not be HTML escaped: & " < >
59
60 - name: Ampersand
61 desc: Ampersand should interpolate without HTML escaping.
62 data: { forbidden: '& " < >' }
63 template: |
64 These characters should not be HTML escaped: {{&forbidden}}
65 expected: |
66 These characters should not be HTML escaped: & " < >
67
68 - name: Basic Integer Interpolation
69 desc: Integers should interpolate seamlessly.
70 data: { mph: 85 }
71 template: '"{{mph}} miles an hour!"'
72 expected: '"85 miles an hour!"'
73
74 - name: Triple Mustache Integer Interpolation
75 desc: Integers should interpolate seamlessly.
76 data: { mph: 85 }
77 template: '"{{{mph}}} miles an hour!"'
78 expected: '"85 miles an hour!"'
79
80 - name: Ampersand Integer Interpolation
81 desc: Integers should interpolate seamlessly.
82 data: { mph: 85 }
83 template: '"{{&mph}} miles an hour!"'
84 expected: '"85 miles an hour!"'
85
86 - name: Basic Decimal Interpolation
87 desc: Decimals should interpolate seamlessly with proper significance.
88 data: { power: 1.210 }
89 template: '"{{power}} jiggawatts!"'
90 expected: '"1.21 jiggawatts!"'
91
92 - name: Triple Mustache Decimal Interpolation
93 desc: Decimals should interpolate seamlessly with proper significance.
94 data: { power: 1.210 }
95 template: '"{{{power}}} jiggawatts!"'
96 expected: '"1.21 jiggawatts!"'
97
98 - name: Ampersand Decimal Interpolation
99 desc: Decimals should interpolate seamlessly with proper significance.
100 data: { power: 1.210 }
101 template: '"{{&power}} jiggawatts!"'
102 expected: '"1.21 jiggawatts!"'
103
104 # Context Misses
105
106 - name: Basic Context Miss Interpolation
107 desc: Failed context lookups should default to empty strings.
108 data: { }
109 template: "I ({{cannot}}) be seen!"
110 expected: "I () be seen!"
111
112 - name: Triple Mustache Context Miss Interpolation
113 desc: Failed context lookups should default to empty strings.
114 data: { }
115 template: "I ({{{cannot}}}) be seen!"
116 expected: "I () be seen!"
117
118 - name: Ampersand Context Miss Interpolation
119 desc: Failed context lookups should default to empty strings.
120 data: { }
121 template: "I ({{&cannot}}) be seen!"
122 expected: "I () be seen!"
123
124 # Dotted Names
125
126 - name: Dotted Names - Basic Interpolation
127 desc: Dotted names should be considered a form of shorthand for sections.
128 data: { person: { name: 'Joe' } }
129 template: '"{{person.name}}" == "{{#person}}{{name}}{{/person}}"'
130 expected: '"Joe" == "Joe"'
131
132 - name: Dotted Names - Triple Mustache Interpolation
133 desc: Dotted names should be considered a form of shorthand for sections.
134 data: { person: { name: 'Joe' } }
135 template: '"{{{person.name}}}" == "{{#person}}{{{name}}}{{/person}}"'
136 expected: '"Joe" == "Joe"'
137
138 - name: Dotted Names - Ampersand Interpolation
139 desc: Dotted names should be considered a form of shorthand for sections.
140 data: { person: { name: 'Joe' } }
141 template: '"{{&person.name}}" == "{{#person}}{{&name}}{{/person}}"'
142 expected: '"Joe" == "Joe"'
143
144 - name: Dotted Names - Arbitrary Depth
145 desc: Dotted names should be functional to any level of nesting.
146 data:
147 a: { b: { c: { d: { e: { name: 'Phil' } } } } }
148 template: '"{{a.b.c.d.e.name}}" == "Phil"'
149 expected: '"Phil" == "Phil"'
150
151 - name: Dotted Names - Broken Chains
152 desc: Any falsey value prior to the last part of the name should yield ''.
153 data:
154 a: { }
155 template: '"{{a.b.c}}" == ""'
156 expected: '"" == ""'
157
158 - name: Dotted Names - Broken Chain Resolution
159 desc: Each part of a dotted name should resolve only against its parent.
160 data:
161 a: { b: { } }
162 c: { name: 'Jim' }
163 template: '"{{a.b.c.name}}" == ""'
164 expected: '"" == ""'
165
166 - name: Dotted Names - Initial Resolution
167 desc: The first part of a dotted name should resolve as any other name.
168 data:
169 a: { b: { c: { d: { e: { name: 'Phil' } } } } }
170 b: { c: { d: { e: { name: 'Wrong' } } } }
171 template: '"{{#a}}{{b.c.d.e.name}}{{/a}}" == "Phil"'
172 expected: '"Phil" == "Phil"'
173
174 - name: Dotted Names - Context Precedence
175 desc: Dotted names should be resolved against former resolutions.
176 data:
177 a: { b: { } }
178 b: { c: 'ERROR' }
179 template: '{{#a}}{{b.c}}{{/a}}'
180 expected: ''
181
182 # Whitespace Sensitivity
183
184 - name: Interpolation - Surrounding Whitespace
185 desc: Interpolation should not alter surrounding whitespace.
186 data: { string: '---' }
187 template: '| {{string}} |'
188 expected: '| --- |'
189
190 - name: Triple Mustache - Surrounding Whitespace
191 desc: Interpolation should not alter surrounding whitespace.
192 data: { string: '---' }
193 template: '| {{{string}}} |'
194 expected: '| --- |'
195
196 - name: Ampersand - Surrounding Whitespace
197 desc: Interpolation should not alter surrounding whitespace.
198 data: { string: '---' }
199 template: '| {{&string}} |'
200 expected: '| --- |'
201
202 - name: Interpolation - Standalone
203 desc: Standalone interpolation should not alter surrounding whitespace.
204 data: { string: '---' }
205 template: " {{string}}\n"
206 expected: " ---\n"
207
208 - name: Triple Mustache - Standalone
209 desc: Standalone interpolation should not alter surrounding whitespace.
210 data: { string: '---' }
211 template: " {{{string}}}\n"
212 expected: " ---\n"
213
214 - name: Ampersand - Standalone
215 desc: Standalone interpolation should not alter surrounding whitespace.
216 data: { string: '---' }
217 template: " {{&string}}\n"
218 expected: " ---\n"
219
220 # Whitespace Insensitivity
221
222 - name: Interpolation With Padding
223 desc: Superfluous in-tag whitespace should be ignored.
224 data: { string: "---" }
225 template: '|{{ string }}|'
226 expected: '|---|'
227
228 - name: Triple Mustache With Padding
229 desc: Superfluous in-tag whitespace should be ignored.
230 data: { string: "---" }
231 template: '|{{{ string }}}|'
232 expected: '|---|'
233
234 - name: Ampersand With Padding
235 desc: Superfluous in-tag whitespace should be ignored.
236 data: { string: "---" }
237 template: '|{{& string }}|'
238 expected: '|---|'
OLDNEW
« no previous file with comments | « pkg/mustache/test/spec/interpolation.json ('k') | pkg/mustache/test/spec/inverted.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698