From a2b4bec7397971d24db92ced09004b7ffc322e48 Mon Sep 17 00:00:00 2001 From: Julian Gonggrijp Date: Mon, 19 Apr 2021 02:00:26 +0200 Subject: Specify interpolation behavior for implicit iterator (#82) --- specs/interpolation.json | 35 +++++++++++++++++++++++++++++++++++ specs/interpolation.yml | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/specs/interpolation.json b/specs/interpolation.json index 1718e1c..170e00f 100644 --- a/specs/interpolation.json +++ b/specs/interpolation.json @@ -244,6 +244,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: & " < >\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.", diff --git a/specs/interpolation.yml b/specs/interpolation.yml index 1b6fff1..91d0019 100644 --- a/specs/interpolation.yml +++ b/specs/interpolation.yml @@ -179,6 +179,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: & " < > + + - 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 -- cgit v1.2.1