-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Additional inheritance specs for block reindentation #131
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is however not exactly the same as a single standalone partial tag, because that would conflict with the existing "Inherit indentation" spec on lines 154-164. "Standalone" here mostly refers to whether the block as a whole will be indented. Contrary to the previous spec, if the end section tag is not standalone by itself, then the trailing newline will not be removed from the output if the block ends up being empty. |
||
data: {} | ||
template: | | ||
{{<parent}}{{$block}} | ||
one | ||
two{{/block}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note this little tweak I had to make here. If I had put the |
||
{{/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}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here, I'm avoiding the double newline problem by making the block tag and the end section tag standalone by themselves, so their trailing newlines are removed from the output. |
||
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is, this pair of tags behaves exactly like a single standalone partial tag.