aboutsummaryrefslogtreecommitdiffstats
path: root/tests/template/delimiters.yml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/template/delimiters.yml')
-rw-r--r--tests/template/delimiters.yml158
1 files changed, 158 insertions, 0 deletions
diff --git a/tests/template/delimiters.yml b/tests/template/delimiters.yml
new file mode 100644
index 0000000..ce80b17
--- /dev/null
+++ b/tests/template/delimiters.yml
@@ -0,0 +1,158 @@
+overview: |
+ Set Delimiter tags are used to change the tag delimiters for all content
+ following the tag in the current compilation unit.
+
+ The tag's content MUST be any two non-whitespace sequences (separated by
+ whitespace) EXCEPT an equals sign ('=') followed by the current closing
+ delimiter.
+
+ Set Delimiter tags SHOULD be treated as standalone when appropriate.
+tests:
+ - name: Pair Behavior
+ desc: The equals sign (used on both sides) should permit delimiter changes.
+ data: { text: 'Hey!' }
+ template: '{{=<% %>=}}(<%text%>)'
+ expected: '(Hey!)'
+
+ - name: Special Characters
+ desc: Characters with special meaning regexen should be valid delimiters.
+ data: { text: 'It worked!' }
+ template: '({{=[ ]=}}[text])'
+ expected: '(It worked!)'
+
+ - name: Sections
+ desc: Delimiters set outside sections should persist.
+ data: { section: true, data: 'I got interpolated.' }
+ template: |
+ [
+ {{#section}}
+ {{data}}
+ |data|
+ {{/section}}
+
+ {{= | | =}}
+ |#section|
+ {{data}}
+ |data|
+ |/section|
+ ]
+ expected: |
+ [
+ I got interpolated.
+ |data|
+
+ {{data}}
+ I got interpolated.
+ ]
+
+ - name: Inverted Sections
+ desc: Delimiters set outside inverted sections should persist.
+ data: { section: false, data: 'I got interpolated.' }
+ template: |
+ [
+ {{^section}}
+ {{data}}
+ |data|
+ {{/section}}
+
+ {{= | | =}}
+ |^section|
+ {{data}}
+ |data|
+ |/section|
+ ]
+ expected: |
+ [
+ I got interpolated.
+ |data|
+
+ {{data}}
+ I got interpolated.
+ ]
+
+ - name: Partial Inheritence
+ desc: Delimiters set in a parent template should not affect a partial.
+ data: { value: 'yes' }
+ partials:
+ include: '.{{value}}.'
+ template: |
+ [ {{>include}} ]
+ {{= | | =}}
+ [ |>include| ]
+ expected: |
+ [ .yes. ]
+ [ .yes. ]
+
+ - name: Post-Partial Behavior
+ desc: Delimiters set in a partial should not affect the parent template.
+ data: { value: 'yes' }
+ partials:
+ include: '.{{value}}. {{= | | =}} .|value|.'
+ template: |
+ [ {{>include}} ]
+ [ .{{value}}. .|value|. ]
+ expected: |
+ [ .yes. .yes. ]
+ [ .yes. .|value|. ]
+
+ # Whitespace Sensitivity
+
+ - name: Surrounding Whitespace
+ desc: Surrounding whitespace should be left untouched.
+ data: { }
+ template: '| {{=@ @=}} |'
+ expected: '| |'
+
+ - name: Outlying Whitespace (Inline)
+ desc: Whitespace should be left untouched.
+ data: { }
+ template: " | {{=@ @=}}\n"
+ expected: " | \n"
+
+ - name: Standalone Tag
+ desc: Standalone lines should be removed from the template.
+ data: { }
+ template: |
+ Begin.
+ {{=@ @=}}
+ End.
+ expected: |
+ Begin.
+ End.
+
+ - name: Indented Standalone Tag
+ desc: Indented standalone lines should be removed from the template.
+ data: { }
+ template: |
+ Begin.
+ {{=@ @=}}
+ End.
+ expected: |
+ Begin.
+ End.
+
+ - name: Standalone Line Endings
+ desc: '"\r\n" should be considered a newline for standalone tags.'
+ data: { }
+ template: "|\r\n{{= @ @ =}}\r\n|"
+ expected: "|\r\n|"
+
+ - name: Standalone Without Previous Line
+ desc: Standalone tags should not require a newline to precede them.
+ data: { }
+ template: " {{=@ @=}}\n="
+ expected: "="
+
+ - name: Standalone Without Newline
+ desc: Standalone tags should not require a newline to follow them.
+ data: { }
+ template: "=\n {{=@ @=}}"
+ expected: "=\n"
+
+ # Whitespace Insensitivity
+
+ - name: Pair with Padding
+ desc: Superfluous in-tag whitespace should be ignored.
+ data: { }
+ template: '|{{= @ @ =}}|'
+ expected: '||'