Skip to content

Commit 380fcb0

Browse files
authored
Merge pull request #131 from jgonggrijp/inheritance-indentation
Additional inheritance specs for block reindentation
2 parents ff88367 + 7834503 commit 380fcb0

File tree

2 files changed

+145
-0
lines changed

2 files changed

+145
-0
lines changed

specs/~inheritance.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,62 @@
245245
"parent": "{{#nested}}{{$block}}You say {{fruit}}.{{/block}}{{/nested}}"
246246
},
247247
"expected": "I say bananas."
248+
},
249+
{
250+
"name": "Standalone parent",
251+
"desc": "A parent's opening and closing tags need not be on separate lines in order to be standalone",
252+
"data": {
253+
},
254+
"template": "Hi,\n {{<parent}}{{/parent}}\n",
255+
"partials": {
256+
"parent": "one\ntwo\n"
257+
},
258+
"expected": "Hi,\n one\n two\n"
259+
},
260+
{
261+
"name": "Standalone block",
262+
"desc": "A block's opening and closing tags need not be on separate lines in order to be standalone",
263+
"data": {
264+
},
265+
"template": "{{<parent}}{{$block}}\none\ntwo{{/block}}\n{{/parent}}\n",
266+
"partials": {
267+
"parent": "Hi,\n {{$block}}{{/block}}\n"
268+
},
269+
"expected": "Hi,\n one\n two\n"
270+
},
271+
{
272+
"name": "Block reindentation",
273+
"desc": "Block indentation is removed at the site of definition and added at the site of expansion",
274+
"data": {
275+
},
276+
"template": "{{<parent}}{{$block}}\n one\n two\n{{/block}}{{/parent}}\n",
277+
"partials": {
278+
"parent": "Hi,\n {{$block}}\n {{/block}}\n"
279+
},
280+
"expected": "Hi,\n one\n two\n"
281+
},
282+
{
283+
"name": "Intrinsic indentation",
284+
"desc": "When the block opening tag is standalone, indentation is determined by default content",
285+
"data": {
286+
},
287+
"template": "{{<parent}}{{$block}}\none\ntwo\n{{/block}}{{/parent}}\n",
288+
"partials": {
289+
"parent": "Hi,\n{{$block}}\n default\n{{/block}}\n"
290+
},
291+
"expected": "Hi,\n one\n two\n"
292+
},
293+
{
294+
"name": "Nested block reindentation",
295+
"desc": "Nested blocks are reindented relative to the surrounding block",
296+
"data": {
297+
},
298+
"template": "{{<parent}}{{$nested}}\nthree\n{{/nested}}{{/parent}}\n",
299+
"partials": {
300+
"parent": "{{<grandparent}}{{$block}}\n one\n {{$nested}}\n two\n {{/nested}}\n{{/block}}{{/grandparent}}\n",
301+
"grandparent": "{{$block}}default{{/block}}"
302+
},
303+
"expected": "one\n three\n"
248304
}
249305
]
250306
}

specs/~inheritance.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,92 @@ tests:
235235
partials:
236236
parent: "{{#nested}}{{$block}}You say {{fruit}}.{{/block}}{{/nested}}"
237237
expected: I say bananas.
238+
239+
- name: Standalone parent
240+
desc: A parent's opening and closing tags need not be on separate lines in order to be standalone
241+
data: {}
242+
template: |
243+
Hi,
244+
{{<parent}}{{/parent}}
245+
partials:
246+
parent: |
247+
one
248+
two
249+
expected: |
250+
Hi,
251+
one
252+
two
253+
254+
- name: Standalone block
255+
desc: A block's opening and closing tags need not be on separate lines in order to be standalone
256+
data: {}
257+
template: |
258+
{{<parent}}{{$block}}
259+
one
260+
two{{/block}}
261+
{{/parent}}
262+
partials:
263+
parent: |
264+
Hi,
265+
{{$block}}{{/block}}
266+
expected: |
267+
Hi,
268+
one
269+
two
270+
271+
- name: Block reindentation
272+
desc: Block indentation is removed at the site of definition and added at the site of expansion
273+
data: {}
274+
template: |
275+
{{<parent}}{{$block}}
276+
one
277+
two
278+
{{/block}}{{/parent}}
279+
partials:
280+
parent: |
281+
Hi,
282+
{{$block}}
283+
{{/block}}
284+
expected: |
285+
Hi,
286+
one
287+
two
288+
289+
- name: Intrinsic indentation
290+
desc: When the block opening tag is standalone, indentation is determined by default content
291+
data: {}
292+
template: |
293+
{{<parent}}{{$block}}
294+
one
295+
two
296+
{{/block}}{{/parent}}
297+
partials:
298+
parent: |
299+
Hi,
300+
{{$block}}
301+
default
302+
{{/block}}
303+
expected: |
304+
Hi,
305+
one
306+
two
307+
308+
- name: Nested block reindentation
309+
desc: Nested blocks are reindented relative to the surrounding block
310+
data: {}
311+
template: |
312+
{{<parent}}{{$nested}}
313+
three
314+
{{/nested}}{{/parent}}
315+
partials:
316+
parent: |
317+
{{<grandparent}}{{$block}}
318+
one
319+
{{$nested}}
320+
two
321+
{{/nested}}
322+
{{/block}}{{/grandparent}}
323+
grandparent: "{{$block}}default{{/block}}"
324+
expected: |
325+
one
326+
three

0 commit comments

Comments
 (0)