diff options
-rw-r--r-- | specs/~inheritance.json | 15 | ||||
-rw-r--r-- | specs/~inheritance.yml | 11 |
2 files changed, 26 insertions, 0 deletions
diff --git a/specs/~inheritance.json b/specs/~inheritance.json index fedb34b..0a6878b 100644 --- a/specs/~inheritance.json +++ b/specs/~inheritance.json @@ -230,6 +230,21 @@ "parent": "{{$foo}}default content{{/foo}}" }, "expected": "default content" + }, + { + "name": "Block scope", + "desc": "Scope of a substituted block is evaluated in the context of the parent template", + "data": { + "fruit": "apples", + "nested": { + "fruit": "bananas" + } + }, + "template": "{{<parent}}{{$block}}I say {{fruit}}.{{/block}}{{/parent}}", + "partials": { + "parent": "{{#nested}}{{$block}}You say {{fruit}}.{{/block}}{{/nested}}" + }, + "expected": "I say bananas." } ] } diff --git a/specs/~inheritance.yml b/specs/~inheritance.yml index 07fa081..5a24ba8 100644 --- a/specs/~inheritance.yml +++ b/specs/~inheritance.yml @@ -224,3 +224,14 @@ tests: partials: parent: "{{$foo}}default content{{/foo}}" expected: default content + + - name: Block scope + desc: Scope of a substituted block is evaluated in the context of the parent template + data: + fruit: apples + nested: + fruit: bananas + template: "{{<parent}}{{$block}}I say {{fruit}}.{{/block}}{{/parent}}" + partials: + parent: "{{#nested}}{{$block}}You say {{fruit}}.{{/block}}{{/nested}}" + expected: I say bananas. |