summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Appel <Dan.appel00@gmail.com>2021-05-02 16:22:35 -0700
committerGitHub <noreply@github.com>2021-05-02 16:22:35 -0700
commit7b09c52a149563d53156e7abcff3dde02f7b5b9d (patch)
tree9986148a30021c056b196e82eaba87047b42deee
parent84f81d1252d0dd064f672ff4d52d09078826c0cd (diff)
parenta2b4bec7397971d24db92ced09004b7ffc322e48 (diff)
downloadmustache-spec-7b09c52a149563d53156e7abcff3dde02f7b5b9d.tar.gz
Merge pull request #124 from jgonggrijp/implicit-iterator-interpolationv1.2.1
Specify interpolation behavior for implicit iterator
-rw-r--r--specs/interpolation.json35
-rw-r--r--specs/interpolation.yml40
2 files changed, 75 insertions, 0 deletions
diff --git a/specs/interpolation.json b/specs/interpolation.json
index d422dc3..d758657 100644
--- a/specs/interpolation.json
+++ b/specs/interpolation.json
@@ -272,6 +272,41 @@
"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.",
"data": {
diff --git a/specs/interpolation.yml b/specs/interpolation.yml
index 9410a30..aae2cf4 100644
--- a/specs/interpolation.yml
+++ b/specs/interpolation.yml
@@ -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