OLD | NEW |
(Empty) | |
| 1 overview: | |
| 2 Partial tags are used to expand an external template into the current |
| 3 template. |
| 4 |
| 5 The tag's content MUST be a non-whitespace character sequence NOT containing |
| 6 the current closing delimiter. |
| 7 |
| 8 This tag's content names the partial to inject. Set Delimiter tags MUST NOT |
| 9 affect the parsing of a partial. The partial MUST be rendered against the |
| 10 context stack local to the tag. If the named partial cannot be found, the |
| 11 empty string SHOULD be used instead, as in interpolations. |
| 12 |
| 13 Partial tags SHOULD be treated as standalone when appropriate. If this tag |
| 14 is used standalone, any whitespace preceding the tag should treated as |
| 15 indentation, and prepended to each line of the partial before rendering. |
| 16 tests: |
| 17 - name: Basic Behavior |
| 18 desc: The greater-than operator should expand to the named partial. |
| 19 data: { } |
| 20 template: '"{{>text}}"' |
| 21 partials: { text: 'from partial' } |
| 22 expected: '"from partial"' |
| 23 |
| 24 - name: Failed Lookup |
| 25 desc: The empty string should be used when the named partial is not found. |
| 26 data: { } |
| 27 template: '"{{>text}}"' |
| 28 partials: { } |
| 29 expected: '""' |
| 30 |
| 31 - name: Context |
| 32 desc: The greater-than operator should operate within the current context. |
| 33 data: { text: 'content' } |
| 34 template: '"{{>partial}}"' |
| 35 partials: { partial: '*{{text}}*' } |
| 36 expected: '"*content*"' |
| 37 |
| 38 - name: Recursion |
| 39 desc: The greater-than operator should properly recurse. |
| 40 data: { content: "X", nodes: [ { content: "Y", nodes: [] } ] } |
| 41 template: '{{>node}}' |
| 42 partials: { node: '{{content}}<{{#nodes}}{{>node}}{{/nodes}}>' } |
| 43 expected: 'X<Y<>>' |
| 44 |
| 45 # Whitespace Sensitivity |
| 46 |
| 47 - name: Surrounding Whitespace |
| 48 desc: The greater-than operator should not alter surrounding whitespace. |
| 49 data: { } |
| 50 template: '| {{>partial}} |' |
| 51 partials: { partial: "\t|\t" } |
| 52 expected: "| \t|\t |" |
| 53 |
| 54 - name: Inline Indentation |
| 55 desc: Whitespace should be left untouched. |
| 56 data: { data: '|' } |
| 57 template: " {{data}} {{> partial}}\n" |
| 58 partials: { partial: ">\n>" } |
| 59 expected: " | >\n>\n" |
| 60 |
| 61 - name: Standalone Line Endings |
| 62 desc: '"\r\n" should be considered a newline for standalone tags.' |
| 63 data: { } |
| 64 template: "|\r\n{{>partial}}\r\n|" |
| 65 partials: { partial: ">" } |
| 66 expected: "|\r\n>|" |
| 67 |
| 68 - name: Standalone Without Previous Line |
| 69 desc: Standalone tags should not require a newline to precede them. |
| 70 data: { } |
| 71 template: " {{>partial}}\n>" |
| 72 partials: { partial: ">\n>"} |
| 73 expected: " >\n >>" |
| 74 |
| 75 - name: Standalone Without Newline |
| 76 desc: Standalone tags should not require a newline to follow them. |
| 77 data: { } |
| 78 template: ">\n {{>partial}}" |
| 79 partials: { partial: ">\n>" } |
| 80 expected: ">\n >\n >" |
| 81 |
| 82 - name: Standalone Indentation |
| 83 desc: Each line of the partial should be indented before rendering. |
| 84 data: { content: "<\n->" } |
| 85 template: | |
| 86 \ |
| 87 {{>partial}} |
| 88 / |
| 89 partials: |
| 90 partial: | |
| 91 | |
| 92 {{{content}}} |
| 93 | |
| 94 expected: | |
| 95 \ |
| 96 | |
| 97 < |
| 98 -> |
| 99 | |
| 100 / |
| 101 |
| 102 # Whitespace Insensitivity |
| 103 |
| 104 - name: Padding Whitespace |
| 105 desc: Superfluous in-tag whitespace should be ignored. |
| 106 data: { boolean: true } |
| 107 template: "|{{> partial }}|" |
| 108 partials: { partial: "[]" } |
| 109 expected: '|[]|' |
OLD | NEW |