OLD | NEW |
(Empty) | |
| 1 overview: | |
| 2 Set Delimiter tags are used to change the tag delimiters for all content |
| 3 following the tag in the current compilation unit. |
| 4 |
| 5 The tag's content MUST be any two non-whitespace sequences (separated by |
| 6 whitespace) EXCEPT an equals sign ('=') followed by the current closing |
| 7 delimiter. |
| 8 |
| 9 Set Delimiter tags SHOULD be treated as standalone when appropriate. |
| 10 tests: |
| 11 - name: Pair Behavior |
| 12 desc: The equals sign (used on both sides) should permit delimiter changes. |
| 13 data: { text: 'Hey!' } |
| 14 template: '{{=<% %>=}}(<%text%>)' |
| 15 expected: '(Hey!)' |
| 16 |
| 17 - name: Special Characters |
| 18 desc: Characters with special meaning regexen should be valid delimiters. |
| 19 data: { text: 'It worked!' } |
| 20 template: '({{=[ ]=}}[text])' |
| 21 expected: '(It worked!)' |
| 22 |
| 23 - name: Sections |
| 24 desc: Delimiters set outside sections should persist. |
| 25 data: { section: true, data: 'I got interpolated.' } |
| 26 template: | |
| 27 [ |
| 28 {{#section}} |
| 29 {{data}} |
| 30 |data| |
| 31 {{/section}} |
| 32 |
| 33 {{= | | =}} |
| 34 |#section| |
| 35 {{data}} |
| 36 |data| |
| 37 |/section| |
| 38 ] |
| 39 expected: | |
| 40 [ |
| 41 I got interpolated. |
| 42 |data| |
| 43 |
| 44 {{data}} |
| 45 I got interpolated. |
| 46 ] |
| 47 |
| 48 - name: Inverted Sections |
| 49 desc: Delimiters set outside inverted sections should persist. |
| 50 data: { section: false, data: 'I got interpolated.' } |
| 51 template: | |
| 52 [ |
| 53 {{^section}} |
| 54 {{data}} |
| 55 |data| |
| 56 {{/section}} |
| 57 |
| 58 {{= | | =}} |
| 59 |^section| |
| 60 {{data}} |
| 61 |data| |
| 62 |/section| |
| 63 ] |
| 64 expected: | |
| 65 [ |
| 66 I got interpolated. |
| 67 |data| |
| 68 |
| 69 {{data}} |
| 70 I got interpolated. |
| 71 ] |
| 72 |
| 73 - name: Partial Inheritence |
| 74 desc: Delimiters set in a parent template should not affect a partial. |
| 75 data: { value: 'yes' } |
| 76 partials: |
| 77 include: '.{{value}}.' |
| 78 template: | |
| 79 [ {{>include}} ] |
| 80 {{= | | =}} |
| 81 [ |>include| ] |
| 82 expected: | |
| 83 [ .yes. ] |
| 84 [ .yes. ] |
| 85 |
| 86 - name: Post-Partial Behavior |
| 87 desc: Delimiters set in a partial should not affect the parent template. |
| 88 data: { value: 'yes' } |
| 89 partials: |
| 90 include: '.{{value}}. {{= | | =}} .|value|.' |
| 91 template: | |
| 92 [ {{>include}} ] |
| 93 [ .{{value}}. .|value|. ] |
| 94 expected: | |
| 95 [ .yes. .yes. ] |
| 96 [ .yes. .|value|. ] |
| 97 |
| 98 # Whitespace Sensitivity |
| 99 |
| 100 - name: Surrounding Whitespace |
| 101 desc: Surrounding whitespace should be left untouched. |
| 102 data: { } |
| 103 template: '| {{=@ @=}} |' |
| 104 expected: '| |' |
| 105 |
| 106 - name: Outlying Whitespace (Inline) |
| 107 desc: Whitespace should be left untouched. |
| 108 data: { } |
| 109 template: " | {{=@ @=}}\n" |
| 110 expected: " | \n" |
| 111 |
| 112 - name: Standalone Tag |
| 113 desc: Standalone lines should be removed from the template. |
| 114 data: { } |
| 115 template: | |
| 116 Begin. |
| 117 {{=@ @=}} |
| 118 End. |
| 119 expected: | |
| 120 Begin. |
| 121 End. |
| 122 |
| 123 - name: Indented Standalone Tag |
| 124 desc: Indented standalone lines should be removed from the template. |
| 125 data: { } |
| 126 template: | |
| 127 Begin. |
| 128 {{=@ @=}} |
| 129 End. |
| 130 expected: | |
| 131 Begin. |
| 132 End. |
| 133 |
| 134 - name: Standalone Line Endings |
| 135 desc: '"\r\n" should be considered a newline for standalone tags.' |
| 136 data: { } |
| 137 template: "|\r\n{{= @ @ =}}\r\n|" |
| 138 expected: "|\r\n|" |
| 139 |
| 140 - name: Standalone Without Previous Line |
| 141 desc: Standalone tags should not require a newline to precede them. |
| 142 data: { } |
| 143 template: " {{=@ @=}}\n=" |
| 144 expected: "=" |
| 145 |
| 146 - name: Standalone Without Newline |
| 147 desc: Standalone tags should not require a newline to follow them. |
| 148 data: { } |
| 149 template: "=\n {{=@ @=}}" |
| 150 expected: "=\n" |
| 151 |
| 152 # Whitespace Insensitivity |
| 153 |
| 154 - name: Pair with Padding |
| 155 desc: Superfluous in-tag whitespace should be ignored. |
| 156 data: { } |
| 157 template: '|{{= @ @ =}}|' |
| 158 expected: '||' |
OLD | NEW |