Skip to content

Commit 7b09c52

Browse files
authored
Merge pull request #124 from jgonggrijp/implicit-iterator-interpolation
Specify interpolation behavior for implicit iterator
2 parents 84f81d1 + a2b4bec commit 7b09c52

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

specs/interpolation.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,41 @@
271271
"template": "{{#a}}{{b.c}}{{/a}}",
272272
"expected": ""
273273
},
274+
{
275+
"name": "Implicit Iterators - Basic Interpolation",
276+
"desc": "Unadorned tags should interpolate content into the template.",
277+
"data": "world",
278+
"template": "Hello, {{.}}!\n",
279+
"expected": "Hello, world!\n"
280+
},
281+
{
282+
"name": "Implicit Iterators - HTML Escaping",
283+
"desc": "Basic interpolation should be HTML escaped.",
284+
"data": "& \" < >",
285+
"template": "These characters should be HTML escaped: {{.}}\n",
286+
"expected": "These characters should be HTML escaped: &amp; &quot; &lt; &gt;\n"
287+
},
288+
{
289+
"name": "Implicit Iterators - Triple Mustache",
290+
"desc": "Triple mustaches should interpolate without HTML escaping.",
291+
"data": "& \" < >",
292+
"template": "These characters should not be HTML escaped: {{{.}}}\n",
293+
"expected": "These characters should not be HTML escaped: & \" < >\n"
294+
},
295+
{
296+
"name": "Implicit Iterators - Ampersand",
297+
"desc": "Ampersand should interpolate without HTML escaping.",
298+
"data": "& \" < >",
299+
"template": "These characters should not be HTML escaped: {{&.}}\n",
300+
"expected": "These characters should not be HTML escaped: & \" < >\n"
301+
},
302+
{
303+
"name": "Implicit Iterators - Basic Integer Interpolation",
304+
"desc": "Integers should interpolate seamlessly.",
305+
"data": 85,
306+
"template": "\"{{.}} miles an hour!\"",
307+
"expected": "\"85 miles an hour!\""
308+
},
274309
{
275310
"name": "Interpolation - Surrounding Whitespace",
276311
"desc": "Interpolation should not alter surrounding whitespace.",

specs/interpolation.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,46 @@ tests:
197197
template: '{{#a}}{{b.c}}{{/a}}'
198198
expected: ''
199199

200+
# Implicit Iterators
201+
202+
- name: Implicit Iterators - Basic Interpolation
203+
desc: Unadorned tags should interpolate content into the template.
204+
data: "world"
205+
template: |
206+
Hello, {{.}}!
207+
expected: |
208+
Hello, world!
209+
210+
- name: Implicit Iterators - HTML Escaping
211+
desc: Basic interpolation should be HTML escaped.
212+
data: '& " < >'
213+
template: |
214+
These characters should be HTML escaped: {{.}}
215+
expected: |
216+
These characters should be HTML escaped: &amp; &quot; &lt; &gt;
217+
218+
- name: Implicit Iterators - Triple Mustache
219+
desc: Triple mustaches should interpolate without HTML escaping.
220+
data: '& " < >'
221+
template: |
222+
These characters should not be HTML escaped: {{{.}}}
223+
expected: |
224+
These characters should not be HTML escaped: & " < >
225+
226+
- name: Implicit Iterators - Ampersand
227+
desc: Ampersand should interpolate without HTML escaping.
228+
data: '& " < >'
229+
template: |
230+
These characters should not be HTML escaped: {{&.}}
231+
expected: |
232+
These characters should not be HTML escaped: & " < >
233+
234+
- name: Implicit Iterators - Basic Integer Interpolation
235+
desc: Integers should interpolate seamlessly.
236+
data: 85
237+
template: '"{{.}} miles an hour!"'
238+
expected: '"85 miles an hour!"'
239+
200240
# Whitespace Sensitivity
201241

202242
- name: Interpolation - Surrounding Whitespace

0 commit comments

Comments
 (0)