Skip to content

Commit

Permalink
Merge pull request #131 from jgonggrijp/inheritance-indentation
Browse files Browse the repository at this point in the history
Additional inheritance specs for block reindentation
  • Loading branch information
jgonggrijp committed Jan 26, 2024
2 parents ff88367 + 7834503 commit 380fcb0
Show file tree
Hide file tree
Showing 2 changed files with 145 additions and 0 deletions.
56 changes: 56 additions & 0 deletions specs/~inheritance.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,62 @@
"parent": "{{#nested}}{{$block}}You say {{fruit}}.{{/block}}{{/nested}}"
},
"expected": "I say bananas."
},
{
"name": "Standalone parent",
"desc": "A parent's opening and closing tags need not be on separate lines in order to be standalone",
"data": {
},
"template": "Hi,\n {{<parent}}{{/parent}}\n",
"partials": {
"parent": "one\ntwo\n"
},
"expected": "Hi,\n one\n two\n"
},
{
"name": "Standalone block",
"desc": "A block's opening and closing tags need not be on separate lines in order to be standalone",
"data": {
},
"template": "{{<parent}}{{$block}}\none\ntwo{{/block}}\n{{/parent}}\n",
"partials": {
"parent": "Hi,\n {{$block}}{{/block}}\n"
},
"expected": "Hi,\n one\n two\n"
},
{
"name": "Block reindentation",
"desc": "Block indentation is removed at the site of definition and added at the site of expansion",
"data": {
},
"template": "{{<parent}}{{$block}}\n one\n two\n{{/block}}{{/parent}}\n",
"partials": {
"parent": "Hi,\n {{$block}}\n {{/block}}\n"
},
"expected": "Hi,\n one\n two\n"
},
{
"name": "Intrinsic indentation",
"desc": "When the block opening tag is standalone, indentation is determined by default content",
"data": {
},
"template": "{{<parent}}{{$block}}\none\ntwo\n{{/block}}{{/parent}}\n",
"partials": {
"parent": "Hi,\n{{$block}}\n default\n{{/block}}\n"
},
"expected": "Hi,\n one\n two\n"
},
{
"name": "Nested block reindentation",
"desc": "Nested blocks are reindented relative to the surrounding block",
"data": {
},
"template": "{{<parent}}{{$nested}}\nthree\n{{/nested}}{{/parent}}\n",
"partials": {
"parent": "{{<grandparent}}{{$block}}\n one\n {{$nested}}\n two\n {{/nested}}\n{{/block}}{{/grandparent}}\n",
"grandparent": "{{$block}}default{{/block}}"
},
"expected": "one\n three\n"
}
]
}
89 changes: 89 additions & 0 deletions specs/~inheritance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,92 @@ tests:
partials:
parent: "{{#nested}}{{$block}}You say {{fruit}}.{{/block}}{{/nested}}"
expected: I say bananas.

- name: Standalone parent
desc: A parent's opening and closing tags need not be on separate lines in order to be standalone
data: {}
template: |
Hi,
{{<parent}}{{/parent}}
partials:
parent: |
one
two
expected: |
Hi,
one
two
- name: Standalone block
desc: A block's opening and closing tags need not be on separate lines in order to be standalone
data: {}
template: |
{{<parent}}{{$block}}
one
two{{/block}}
{{/parent}}
partials:
parent: |
Hi,
{{$block}}{{/block}}
expected: |
Hi,
one
two
- name: Block reindentation
desc: Block indentation is removed at the site of definition and added at the site of expansion
data: {}
template: |
{{<parent}}{{$block}}
one
two
{{/block}}{{/parent}}
partials:
parent: |
Hi,
{{$block}}
{{/block}}
expected: |
Hi,
one
two
- name: Intrinsic indentation
desc: When the block opening tag is standalone, indentation is determined by default content
data: {}
template: |
{{<parent}}{{$block}}
one
two
{{/block}}{{/parent}}
partials:
parent: |
Hi,
{{$block}}
default
{{/block}}
expected: |
Hi,
one
two
- name: Nested block reindentation
desc: Nested blocks are reindented relative to the surrounding block
data: {}
template: |
{{<parent}}{{$nested}}
three
{{/nested}}{{/parent}}
partials:
parent: |
{{<grandparent}}{{$block}}
one
{{$nested}}
two
{{/nested}}
{{/block}}{{/grandparent}}
grandparent: "{{$block}}default{{/block}}"
expected: |
one
three

0 comments on commit 380fcb0

Please sign in to comment.