Skip to content

Commit

Permalink
Merge pull request #124 from jgonggrijp/implicit-iterator-interpolation
Browse files Browse the repository at this point in the history
Specify interpolation behavior for implicit iterator
  • Loading branch information
Danappelxx committed May 2, 2021
2 parents 84f81d1 + a2b4bec commit 7b09c52
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
35 changes: 35 additions & 0 deletions specs/interpolation.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,41 @@
"template": "{{#a}}{{b.c}}{{/a}}",
"expected": ""
},
{
"name": "Implicit Iterators - Basic Interpolation",
"desc": "Unadorned tags should interpolate content into the template.",
"data": "world",
"template": "Hello, {{.}}!\n",
"expected": "Hello, world!\n"
},
{
"name": "Implicit Iterators - HTML Escaping",
"desc": "Basic interpolation should be HTML escaped.",
"data": "& \" < >",
"template": "These characters should be HTML escaped: {{.}}\n",
"expected": "These characters should be HTML escaped: &amp; &quot; &lt; &gt;\n"
},
{
"name": "Implicit Iterators - Triple Mustache",
"desc": "Triple mustaches should interpolate without HTML escaping.",
"data": "& \" < >",
"template": "These characters should not be HTML escaped: {{{.}}}\n",
"expected": "These characters should not be HTML escaped: & \" < >\n"
},
{
"name": "Implicit Iterators - Ampersand",
"desc": "Ampersand should interpolate without HTML escaping.",
"data": "& \" < >",
"template": "These characters should not be HTML escaped: {{&.}}\n",
"expected": "These characters should not be HTML escaped: & \" < >\n"
},
{
"name": "Implicit Iterators - Basic Integer Interpolation",
"desc": "Integers should interpolate seamlessly.",
"data": 85,
"template": "\"{{.}} miles an hour!\"",
"expected": "\"85 miles an hour!\""
},
{
"name": "Interpolation - Surrounding Whitespace",
"desc": "Interpolation should not alter surrounding whitespace.",
Expand Down
40 changes: 40 additions & 0 deletions specs/interpolation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,46 @@ tests:
template: '{{#a}}{{b.c}}{{/a}}'
expected: ''

# Implicit Iterators

- name: Implicit Iterators - Basic Interpolation
desc: Unadorned tags should interpolate content into the template.
data: "world"
template: |
Hello, {{.}}!
expected: |
Hello, world!
- name: Implicit Iterators - HTML Escaping
desc: Basic interpolation should be HTML escaped.
data: '& " < >'
template: |
These characters should be HTML escaped: {{.}}
expected: |
These characters should be HTML escaped: &amp; &quot; &lt; &gt;
- name: Implicit Iterators - Triple Mustache
desc: Triple mustaches should interpolate without HTML escaping.
data: '& " < >'
template: |
These characters should not be HTML escaped: {{{.}}}
expected: |
These characters should not be HTML escaped: & " < >
- name: Implicit Iterators - Ampersand
desc: Ampersand should interpolate without HTML escaping.
data: '& " < >'
template: |
These characters should not be HTML escaped: {{&.}}
expected: |
These characters should not be HTML escaped: & " < >
- name: Implicit Iterators - Basic Integer Interpolation
desc: Integers should interpolate seamlessly.
data: 85
template: '"{{.}} miles an hour!"'
expected: '"85 miles an hour!"'

# Whitespace Sensitivity

- name: Interpolation - Surrounding Whitespace
Expand Down

0 comments on commit 7b09c52

Please sign in to comment.