1overview: |
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.
11
12  Partial tags SHOULD be treated as standalone when appropriate.  If this tag
13  is used standalone, any whitespace preceding the tag should treated as
14  indentation, and prepended to each line of the partial before rendering.
15tests:
16  - name: Basic Behavior
17    desc: The greater-than operator should expand to the named partial.
18    data: { }
19    template: '"{{>text}}"'
20    partials: { text: 'from partial' }
21    expected: '"from partial"'
22
23  - name: Context
24    desc: The greater-than operator should operate within the current context.
25    data: { text: 'content' }
26    template: '"{{>partial}}"'
27    partials: { partial: '*{{text}}*' }
28    expected: '"*content*"'
29
30  - name: Recursion
31    desc: The greater-than operator should properly recurse.
32    data: { content: "X", nodes: [ { content: "Y", nodes: [] } ] }
33    template: '{{>node}}'
34    partials: { node: '{{content}}<{{#nodes}}{{>node}}{{/nodes}}>' }
35    expected: 'X<Y<>>'
36
37  # Whitespace Sensitivity
38
39  - name: Surrounding Whitespace
40    desc: The greater-than operator should not alter surrounding whitespace.
41    data: { }
42    template: '| {{>partial}} |'
43    partials: { partial: "\t|\t" }
44    expected: "| \t|\t |"
45
46  - name: Inline Indentation
47    desc: Whitespace should be left untouched.
48    data: { data: '|' }
49    template: "  {{data}}  {{> partial}}\n"
50    partials: { partial: ">\n>" }
51    expected: "  |  >\n>\n"
52
53  - name: Standalone Line Endings
54    desc: '"\r\n" should be considered a newline for standalone tags.'
55    data: { }
56    template: "|\r\n{{>partial}}\r\n|"
57    partials: { partial: ">" }
58    expected: "|\r\n>|"
59
60  - name: Standalone Without Previous Line
61    desc: Standalone tags should not require a newline to precede them.
62    data: { }
63    template: "  {{>partial}}\n>"
64    partials: { partial: ">\n>"}
65    expected: "  >\n  >>"
66
67  - name: Standalone Without Newline
68    desc: Standalone tags should not require a newline to follow them.
69    data: { }
70    template: ">\n  {{>partial}}"
71    partials: { partial: ">\n>" }
72    expected: ">\n  >\n  >"
73
74  - name: Standalone Indentation
75    desc: Each line of the partial should be indented before rendering.
76    data: { content: "<\n->" }
77    template: |
78      \
79       {{>partial}}
80      /
81    partials:
82      partial: |
83        |
84        {{{content}}}
85        |
86    expected: |
87      \
88       |
89       <
90      ->
91       |
92      /
93
94  # Whitespace Insensitivity
95
96  - name: Padding Whitespace
97    desc: Superfluous in-tag whitespace should be ignored.
98    data: { boolean: true }
99    template: "|{{> partial }}|"
100    partials: { partial: "[]" }
101    expected: '|[]|'
102