summaryrefslogtreecommitdiff
path: root/specs/partials.yml
blob: 3b65334e055856bc7ee756af53666bd8f6239622 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
tests:
  - name: Basic Behavior
    desc: The greater-than operator should expand to the named partial.
    data: { }
    template: '"{{>text}}"'
    partials: { text: 'from partial' }
    expected: '"from partial"'

  - name: Context
    desc: The greater-than operator should operate within the current context.
    data: { text: 'content' }
    template: '"{{>partial}}"'
    partials: { partial: '*{{text}}*' }
    expected: '"*content*"'

  - name: Recursion
    desc: The greater-than operator should properly recurse.
    data: { content: "X", nodes: [ { content: "Y", nodes: [] } ] }
    template: '{{>node}}'
    partials: { node: '{{content}}<{{#nodes}}{{>node}}{{/nodes}}>' }
    expected: 'X<Y<>>'

  # Whitespace Sensitivity

  - name: Surrounding Whitespace
    desc: The greater-than operator should not alter surrounding whitespace.
    data: { }
    template: '| {{>partial}} |'
    partials: { partial: "\t|\t" }
    expected: "| \t|\t |"

  - name: Inline Indentation
    desc: Whitespace should be left untouched.
    data: { data: '|' }
    template: "  {{data}}  {{> partial}}\n"
    partials: { partial: ">\n>" }
    expected: "  |  >\n>\n"

  - name: Standalone Indentation
    desc: Each line of the partial should be indented before rendering.
    data: { content: "<\n->" }
    template: |
      \
       {{>partial}}
      /
    partials:
      partial: |
        |
        {{{content}}}
        |
    expected: |
      \
       |
       <
      ->
       |
      /

  # Whitespace Insensitivity

  - name: Padding Whitespace
    desc: Superfluous in-tag whitespace should be ignored.
    data: { boolean: true }
    template: "|{{> partial }}|"
    partials: { partial: "[]" }
    expected: '|[]|'