From ab227509e64961943ca374c09c08b63f59da014a Mon Sep 17 00:00:00 2001 From: Dan Miller Date: Mon, 14 Apr 2014 18:18:30 +0000 Subject: Add template inheritance spec --- specs/inheritance.json | 1 + specs/inheritance.yml | 192 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 193 insertions(+) create mode 100644 specs/inheritance.json create mode 100644 specs/inheritance.yml diff --git a/specs/inheritance.json b/specs/inheritance.json new file mode 100644 index 0000000..07b6311 --- /dev/null +++ b/specs/inheritance.json @@ -0,0 +1 @@ +{"overview":"Parent tags are used to expand an external template into the current template,\nwith optional parameters delimited by block tags.\n\nThese tags' content MUST be a non-whitespace character sequence NOT containing\nthe current closing delimiter; each Parent tag MUST be followed by an End\nSection tag with the same content within the matching parent tag.\n\nBlock tags are used inside of parent tags to assign data onto the context stack \nprior to rendering the parent template. Outside of parent tags, block tags are\nused to indicate where value set in the parent tag should be placed. If no value\nis set then the content in between the block tags, if any, is rendered.\n","tests":[{"name":"Default","desc":"Default content should be rendered if the block isn't overridden","data":{},"template":"{{$title}}Default title{{/title}}\n","expected":"Default title\n"},{"name":"Variable","desc":"Default content renders variables","data":{"bar":"baz"},"template":"{{$foo}}default {{bar}} content{{/foo}}\n","expected":"default baz content\n"},{"name":"Triple Mustache","desc":"Default content renders triple mustache variables","data":{"bar":""},"template":"{{$foo}}default {{{bar}}} content{{/foo}}\n","expected":"default content\n"},{"name":"Sections","desc":"Default content renders sections","data":{"bar":{"baz":"qux"}},"template":"{{$foo}}default {{#bar}}{{baz}}{{/bar}} content{{/foo}}\n","expected":"default qux content\n"},{"name":"Negative Sections","desc":"Default content renders negative sections","data":{"baz":"three"},"template":"{{$foo}}default {{^bar}}{{baz}}{{/bar}} content{{/foo}}\n","expected":"default three content\n"},{"name":"Mustache Injection","desc":"Mustache injection in default content","data":{"bar":{"baz":"{{qux}}"}},"template":"{{$foo}}default {{#bar}}{{baz}}{{/bar}} content{{/foo}}\n","expected":"default {{qux}} content\n"},{"name":"Inherit","desc":"Default content rendered inside included templates","data":{},"template":"{{include}}|{{' } + template: | + {{$foo}}default {{{bar}}} content{{/foo}} + expected: | + default content + + - name: Sections + desc: Default content renders sections + data: { bar: {baz: 'qux'} } + template: | + {{$foo}}default {{#bar}}{{baz}}{{/bar}} content{{/foo}} + expected: | + default qux content + + - name: Negative Sections + desc: Default content renders negative sections + data: { baz: 'three' } + template: | + {{$foo}}default {{^bar}}{{baz}}{{/bar}} content{{/foo}} + expected: | + default three content + + - name: Mustache Injection + desc: Mustache injection in default content + data: {bar: {baz: '{{qux}}'} } + template: | + {{$foo}}default {{#bar}}{{baz}}{{/bar}} content{{/foo}} + expected: | + default {{qux}} content + + - name: Inherit + desc: Default content rendered inside included templates + data: { } + template: | + {{include}}|{{ Date: Mon, 19 Apr 2021 02:26:06 +0200 Subject: Fix inheritance spec whitespace --- specs/inheritance.yml | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/specs/inheritance.yml b/specs/inheritance.yml index 479e834..8881ee5 100644 --- a/specs/inheritance.yml +++ b/specs/inheritance.yml @@ -6,30 +6,31 @@ overview: | the current closing delimiter; each Parent tag MUST be followed by an End Section tag with the same content within the matching parent tag. - Block tags are used inside of parent tags to assign data onto the context stack - prior to rendering the parent template. Outside of parent tags, block tags are - used to indicate where value set in the parent tag should be placed. If no value - is set then the content in between the block tags, if any, is rendered. + Block tags are used inside of parent tags to assign data onto the context + stack prior to rendering the parent template. Outside of parent tags, block + tags are used to indicate where value set in the parent tag should be placed. + If no value is set then the content in between the block tags, if any, is + rendered. tests: - name: Default desc: Default content should be rendered if the block isn't overridden data: { } template: | - {{$title}}Default title{{/title}} + {{$title}}Default title{{/title}} expected: | - Default title + Default title - name: Variable desc: Default content renders variables data: { bar: 'baz' } template: | - {{$foo}}default {{bar}} content{{/foo}} + {{$foo}}default {{bar}} content{{/foo}} expected: | - default baz content + default baz content - name: Triple Mustache desc: Default content renders triple mustache variables - data: { bar: '' } + data: { bar: '' } template: | {{$foo}}default {{{bar}}} content{{/foo}} expected: | @@ -109,6 +110,7 @@ tests: partial: "|{{$stuff}}...{{/stuff}}{{$default}} default{{/default}}|" expected: | test |override1 default| |override2 default| + - name: Override partial with newlines desc: Override partial with newlines data: { } @@ -116,7 +118,7 @@ tests: partials: partial: "{{$ballmer}}peaking{{/ballmer}}" expected: "peaked\n\n:(\n" - + - name: Inherit indentation desc: Inherit indentation when overriding a partial data: { } @@ -124,12 +126,12 @@ tests: partials: partial: | stop: - {{$nineties}}collaborate and listen{{/nineties}} + {{$nineties}}collaborate and listen{{/nineties}} expected: | stop: - hammer time + hammer time - - name: Only one override + - name: Only one override desc: Override one substitution but not the other data: { } template: "{{ Date: Mon, 19 Apr 2021 02:27:30 +0200 Subject: Rebuild inheritance json --- specs/inheritance.json | 236 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 235 insertions(+), 1 deletion(-) diff --git a/specs/inheritance.json b/specs/inheritance.json index 07b6311..809b693 100644 --- a/specs/inheritance.json +++ b/specs/inheritance.json @@ -1 +1,235 @@ -{"overview":"Parent tags are used to expand an external template into the current template,\nwith optional parameters delimited by block tags.\n\nThese tags' content MUST be a non-whitespace character sequence NOT containing\nthe current closing delimiter; each Parent tag MUST be followed by an End\nSection tag with the same content within the matching parent tag.\n\nBlock tags are used inside of parent tags to assign data onto the context stack \nprior to rendering the parent template. Outside of parent tags, block tags are\nused to indicate where value set in the parent tag should be placed. If no value\nis set then the content in between the block tags, if any, is rendered.\n","tests":[{"name":"Default","desc":"Default content should be rendered if the block isn't overridden","data":{},"template":"{{$title}}Default title{{/title}}\n","expected":"Default title\n"},{"name":"Variable","desc":"Default content renders variables","data":{"bar":"baz"},"template":"{{$foo}}default {{bar}} content{{/foo}}\n","expected":"default baz content\n"},{"name":"Triple Mustache","desc":"Default content renders triple mustache variables","data":{"bar":""},"template":"{{$foo}}default {{{bar}}} content{{/foo}}\n","expected":"default content\n"},{"name":"Sections","desc":"Default content renders sections","data":{"bar":{"baz":"qux"}},"template":"{{$foo}}default {{#bar}}{{baz}}{{/bar}} content{{/foo}}\n","expected":"default qux content\n"},{"name":"Negative Sections","desc":"Default content renders negative sections","data":{"baz":"three"},"template":"{{$foo}}default {{^bar}}{{baz}}{{/bar}} content{{/foo}}\n","expected":"default three content\n"},{"name":"Mustache Injection","desc":"Mustache injection in default content","data":{"bar":{"baz":"{{qux}}"}},"template":"{{$foo}}default {{#bar}}{{baz}}{{/bar}} content{{/foo}}\n","expected":"default {{qux}} content\n"},{"name":"Inherit","desc":"Default content rendered inside included templates","data":{},"template":"{{include}}|{{" + }, + "template": "{{$foo}}default {{{bar}}} content{{/foo}}\n", + "expected": "default content\n" + }, + { + "name": "Sections", + "desc": "Default content renders sections", + "data": { + "bar": { + "baz": "qux" + } + }, + "template": "{{$foo}}default {{#bar}}{{baz}}{{/bar}} content{{/foo}}\n", + "expected": "default qux content\n" + }, + { + "name": "Negative Sections", + "desc": "Default content renders negative sections", + "data": { + "baz": "three" + }, + "template": "{{$foo}}default {{^bar}}{{baz}}{{/bar}} content{{/foo}}\n", + "expected": "default three content\n" + }, + { + "name": "Mustache Injection", + "desc": "Mustache injection in default content", + "data": { + "bar": { + "baz": "{{qux}}" + } + }, + "template": "{{$foo}}default {{#bar}}{{baz}}{{/bar}} content{{/foo}}\n", + "expected": "default {{qux}} content\n" + }, + { + "name": "Inherit", + "desc": "Default content rendered inside included templates", + "data": { + }, + "template": "{{include}}|{{ Date: Mon, 19 Apr 2021 02:29:03 +0200 Subject: Mark inheritance spec as optional --- specs/inheritance.json | 235 ------------------------------------------------ specs/inheritance.yml | 194 --------------------------------------- specs/~inheritance.json | 235 ++++++++++++++++++++++++++++++++++++++++++++++++ specs/~inheritance.yml | 194 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 429 insertions(+), 429 deletions(-) delete mode 100644 specs/inheritance.json delete mode 100644 specs/inheritance.yml create mode 100644 specs/~inheritance.json create mode 100644 specs/~inheritance.yml diff --git a/specs/inheritance.json b/specs/inheritance.json deleted file mode 100644 index 809b693..0000000 --- a/specs/inheritance.json +++ /dev/null @@ -1,235 +0,0 @@ -{ - "__ATTN__": "Do not edit this file; changes belong in the appropriate YAML file.", - "overview": "Parent tags are used to expand an external template into the current template,\nwith optional parameters delimited by block tags.\n\nThese tags' content MUST be a non-whitespace character sequence NOT containing\nthe current closing delimiter; each Parent tag MUST be followed by an End\nSection tag with the same content within the matching parent tag.\n\nBlock tags are used inside of parent tags to assign data onto the context\nstack prior to rendering the parent template. Outside of parent tags, block\ntags are used to indicate where value set in the parent tag should be placed.\nIf no value is set then the content in between the block tags, if any, is\nrendered.\n", - "tests": [ - { - "name": "Default", - "desc": "Default content should be rendered if the block isn't overridden", - "data": { - }, - "template": "{{$title}}Default title{{/title}}\n", - "expected": "Default title\n" - }, - { - "name": "Variable", - "desc": "Default content renders variables", - "data": { - "bar": "baz" - }, - "template": "{{$foo}}default {{bar}} content{{/foo}}\n", - "expected": "default baz content\n" - }, - { - "name": "Triple Mustache", - "desc": "Default content renders triple mustache variables", - "data": { - "bar": "" - }, - "template": "{{$foo}}default {{{bar}}} content{{/foo}}\n", - "expected": "default content\n" - }, - { - "name": "Sections", - "desc": "Default content renders sections", - "data": { - "bar": { - "baz": "qux" - } - }, - "template": "{{$foo}}default {{#bar}}{{baz}}{{/bar}} content{{/foo}}\n", - "expected": "default qux content\n" - }, - { - "name": "Negative Sections", - "desc": "Default content renders negative sections", - "data": { - "baz": "three" - }, - "template": "{{$foo}}default {{^bar}}{{baz}}{{/bar}} content{{/foo}}\n", - "expected": "default three content\n" - }, - { - "name": "Mustache Injection", - "desc": "Mustache injection in default content", - "data": { - "bar": { - "baz": "{{qux}}" - } - }, - "template": "{{$foo}}default {{#bar}}{{baz}}{{/bar}} content{{/foo}}\n", - "expected": "default {{qux}} content\n" - }, - { - "name": "Inherit", - "desc": "Default content rendered inside included templates", - "data": { - }, - "template": "{{include}}|{{' } - template: | - {{$foo}}default {{{bar}}} content{{/foo}} - expected: | - default content - - - name: Sections - desc: Default content renders sections - data: { bar: {baz: 'qux'} } - template: | - {{$foo}}default {{#bar}}{{baz}}{{/bar}} content{{/foo}} - expected: | - default qux content - - - name: Negative Sections - desc: Default content renders negative sections - data: { baz: 'three' } - template: | - {{$foo}}default {{^bar}}{{baz}}{{/bar}} content{{/foo}} - expected: | - default three content - - - name: Mustache Injection - desc: Mustache injection in default content - data: {bar: {baz: '{{qux}}'} } - template: | - {{$foo}}default {{#bar}}{{baz}}{{/bar}} content{{/foo}} - expected: | - default {{qux}} content - - - name: Inherit - desc: Default content rendered inside included templates - data: { } - template: | - {{include}}|{{" + }, + "template": "{{$foo}}default {{{bar}}} content{{/foo}}\n", + "expected": "default content\n" + }, + { + "name": "Sections", + "desc": "Default content renders sections", + "data": { + "bar": { + "baz": "qux" + } + }, + "template": "{{$foo}}default {{#bar}}{{baz}}{{/bar}} content{{/foo}}\n", + "expected": "default qux content\n" + }, + { + "name": "Negative Sections", + "desc": "Default content renders negative sections", + "data": { + "baz": "three" + }, + "template": "{{$foo}}default {{^bar}}{{baz}}{{/bar}} content{{/foo}}\n", + "expected": "default three content\n" + }, + { + "name": "Mustache Injection", + "desc": "Mustache injection in default content", + "data": { + "bar": { + "baz": "{{qux}}" + } + }, + "template": "{{$foo}}default {{#bar}}{{baz}}{{/bar}} content{{/foo}}\n", + "expected": "default {{qux}} content\n" + }, + { + "name": "Inherit", + "desc": "Default content rendered inside included templates", + "data": { + }, + "template": "{{include}}|{{' } + template: | + {{$foo}}default {{{bar}}} content{{/foo}} + expected: | + default content + + - name: Sections + desc: Default content renders sections + data: { bar: {baz: 'qux'} } + template: | + {{$foo}}default {{#bar}}{{baz}}{{/bar}} content{{/foo}} + expected: | + default qux content + + - name: Negative Sections + desc: Default content renders negative sections + data: { baz: 'three' } + template: | + {{$foo}}default {{^bar}}{{baz}}{{/bar}} content{{/foo}} + expected: | + default three content + + - name: Mustache Injection + desc: Mustache injection in default content + data: {bar: {baz: '{{qux}}'} } + template: | + {{$foo}}default {{#bar}}{{baz}}{{/bar}} content{{/foo}} + expected: | + default {{qux}} content + + - name: Inherit + desc: Default content rendered inside included templates + data: { } + template: | + {{include}}|{{ Date: Mon, 19 Apr 2021 03:07:08 +0200 Subject: Expand the inheritance overview --- specs/~inheritance.json | 2 +- specs/~inheritance.yml | 50 +++++++++++++++++++++++++++++++++++++------------ 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/specs/~inheritance.json b/specs/~inheritance.json index 809b693..2d4539d 100644 --- a/specs/~inheritance.json +++ b/specs/~inheritance.json @@ -1,6 +1,6 @@ { "__ATTN__": "Do not edit this file; changes belong in the appropriate YAML file.", - "overview": "Parent tags are used to expand an external template into the current template,\nwith optional parameters delimited by block tags.\n\nThese tags' content MUST be a non-whitespace character sequence NOT containing\nthe current closing delimiter; each Parent tag MUST be followed by an End\nSection tag with the same content within the matching parent tag.\n\nBlock tags are used inside of parent tags to assign data onto the context\nstack prior to rendering the parent template. Outside of parent tags, block\ntags are used to indicate where value set in the parent tag should be placed.\nIf no value is set then the content in between the block tags, if any, is\nrendered.\n", + "overview": "Like partials, Parent tags are used to expand an external template into the\ncurrent template. Contrary to partials, Parent tags may contain optional\narguments delimited by block tags. For this reason, Parent tags may also be\nreferred to as Parametric Partials.\n\nThe Parent tags' content MUST be a non-whitespace character sequence NOT\ncontaining the current closing delimiter; each Parent tag MUST be followed by\nan End Section tag with the same content within the matching Parent tag.\n\nThis tag's content names the Parent template to inject. Set Delimiter tags\nMUST NOT affect the parsing of a Parent template. The Parent MUST be rendered\nagainst the context stack local to the tag. If the named Parent cannot be\nfound, the empty string SHOULD be used instead, as in interpolations.\n\nParent tags SHOULD be treated as standalone when appropriate. If this tag is\nused standalone, any whitespace preceding the tag should be treated as\nindentation, and prepended to each line of the Parent before rendering.\n\nThe Block tags' content MUST be a non-whitespace character sequence NOT\ncontaining the current closing delimiter. Each Block tag MUST be followed by\nan End Section tag with the same content within the matching Block tag. This\ntag's content determines the parameter or argument name.\n\nBlock tags may appear both inside and outside of Parent tags. In both cases,\nthey specify a position within the template that can be overridden; it is a\nparameter of the containing template. The template text between the Block tag\nand its matching End Section tag defines the default content to render when\nthe parameter is not overridden from outside.\n\nIn addition, when used inside of a Parent tag, the template text between a\nBlock tag and its matching End Section tag defines content that replaces the\ndefault defined in the Parent template. This content is the argument passed\nto the Parent template.\n\nThe practice of injecting an external template using a Parent tag is referred\nto as inheritance. If the Parent tag includes a Block tag that overrides a\nparameter of the Parent template, this may also be referred to as\nsubstitution.\n", "tests": [ { "name": "Default", diff --git a/specs/~inheritance.yml b/specs/~inheritance.yml index 8881ee5..46eb625 100644 --- a/specs/~inheritance.yml +++ b/specs/~inheritance.yml @@ -1,16 +1,42 @@ overview: | - Parent tags are used to expand an external template into the current template, - with optional parameters delimited by block tags. - - These tags' content MUST be a non-whitespace character sequence NOT containing - the current closing delimiter; each Parent tag MUST be followed by an End - Section tag with the same content within the matching parent tag. - - Block tags are used inside of parent tags to assign data onto the context - stack prior to rendering the parent template. Outside of parent tags, block - tags are used to indicate where value set in the parent tag should be placed. - If no value is set then the content in between the block tags, if any, is - rendered. + Like partials, Parent tags are used to expand an external template into the + current template. Contrary to partials, Parent tags may contain optional + arguments delimited by block tags. For this reason, Parent tags may also be + referred to as Parametric Partials. + + The Parent tags' content MUST be a non-whitespace character sequence NOT + containing the current closing delimiter; each Parent tag MUST be followed by + an End Section tag with the same content within the matching Parent tag. + + This tag's content names the Parent template to inject. Set Delimiter tags + MUST NOT affect the parsing of a Parent template. The Parent MUST be rendered + against the context stack local to the tag. If the named Parent cannot be + found, the empty string SHOULD be used instead, as in interpolations. + + Parent tags SHOULD be treated as standalone when appropriate. If this tag is + used standalone, any whitespace preceding the tag should be treated as + indentation, and prepended to each line of the Parent before rendering. + + The Block tags' content MUST be a non-whitespace character sequence NOT + containing the current closing delimiter. Each Block tag MUST be followed by + an End Section tag with the same content within the matching Block tag. This + tag's content determines the parameter or argument name. + + Block tags may appear both inside and outside of Parent tags. In both cases, + they specify a position within the template that can be overridden; it is a + parameter of the containing template. The template text between the Block tag + and its matching End Section tag defines the default content to render when + the parameter is not overridden from outside. + + In addition, when used inside of a Parent tag, the template text between a + Block tag and its matching End Section tag defines content that replaces the + default defined in the Parent template. This content is the argument passed + to the Parent template. + + The practice of injecting an external template using a Parent tag is referred + to as inheritance. If the Parent tag includes a Block tag that overrides a + parameter of the Parent template, this may also be referred to as + substitution. tests: - name: Default desc: Default content should be rendered if the block isn't overridden -- cgit v1.2.1 From c8ad2318a81d0ac5757182d1f8c8617d08259fcc Mon Sep 17 00:00:00 2001 From: Julian Gonggrijp Date: Mon, 19 Apr 2021 03:22:15 +0200 Subject: Use more consistent terminology in the inheritance specs --- specs/~inheritance.json | 72 ++++++++++++++++++++++++------------------------- specs/~inheritance.yml | 72 ++++++++++++++++++++++++------------------------- 2 files changed, 72 insertions(+), 72 deletions(-) diff --git a/specs/~inheritance.json b/specs/~inheritance.json index 2d4539d..88ebd1e 100644 --- a/specs/~inheritance.json +++ b/specs/~inheritance.json @@ -61,7 +61,7 @@ }, { "name": "Inherit", - "desc": "Default content rendered inside included templates", + "desc": "Default content rendered inside inherited templates", "data": { }, "template": "{{include}}|{{parent}}|{{include}}|{{parent}}|{{ Date: Mon, 19 Apr 2021 03:26:03 +0200 Subject: Clarify the namespaces of Parents and Blocks --- specs/~inheritance.json | 2 +- specs/~inheritance.yml | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/specs/~inheritance.json b/specs/~inheritance.json index 88ebd1e..9453560 100644 --- a/specs/~inheritance.json +++ b/specs/~inheritance.json @@ -1,6 +1,6 @@ { "__ATTN__": "Do not edit this file; changes belong in the appropriate YAML file.", - "overview": "Like partials, Parent tags are used to expand an external template into the\ncurrent template. Contrary to partials, Parent tags may contain optional\narguments delimited by block tags. For this reason, Parent tags may also be\nreferred to as Parametric Partials.\n\nThe Parent tags' content MUST be a non-whitespace character sequence NOT\ncontaining the current closing delimiter; each Parent tag MUST be followed by\nan End Section tag with the same content within the matching Parent tag.\n\nThis tag's content names the Parent template to inject. Set Delimiter tags\nMUST NOT affect the parsing of a Parent template. The Parent MUST be rendered\nagainst the context stack local to the tag. If the named Parent cannot be\nfound, the empty string SHOULD be used instead, as in interpolations.\n\nParent tags SHOULD be treated as standalone when appropriate. If this tag is\nused standalone, any whitespace preceding the tag should be treated as\nindentation, and prepended to each line of the Parent before rendering.\n\nThe Block tags' content MUST be a non-whitespace character sequence NOT\ncontaining the current closing delimiter. Each Block tag MUST be followed by\nan End Section tag with the same content within the matching Block tag. This\ntag's content determines the parameter or argument name.\n\nBlock tags may appear both inside and outside of Parent tags. In both cases,\nthey specify a position within the template that can be overridden; it is a\nparameter of the containing template. The template text between the Block tag\nand its matching End Section tag defines the default content to render when\nthe parameter is not overridden from outside.\n\nIn addition, when used inside of a Parent tag, the template text between a\nBlock tag and its matching End Section tag defines content that replaces the\ndefault defined in the Parent template. This content is the argument passed\nto the Parent template.\n\nThe practice of injecting an external template using a Parent tag is referred\nto as inheritance. If the Parent tag includes a Block tag that overrides a\nparameter of the Parent template, this may also be referred to as\nsubstitution.\n", + "overview": "Like partials, Parent tags are used to expand an external template into the\ncurrent template. Contrary to partials, Parent tags may contain optional\narguments delimited by block tags. For this reason, Parent tags may also be\nreferred to as Parametric Partials.\n\nThe Parent tags' content MUST be a non-whitespace character sequence NOT\ncontaining the current closing delimiter; each Parent tag MUST be followed by\nan End Section tag with the same content within the matching Parent tag.\n\nThis tag's content names the Parent template to inject. Set Delimiter tags\nMUST NOT affect the parsing of a Parent template. The Parent MUST be rendered\nagainst the context stack local to the tag. If the named Parent cannot be\nfound, the empty string SHOULD be used instead, as in interpolations.\n\nParent tags SHOULD be treated as standalone when appropriate. If this tag is\nused standalone, any whitespace preceding the tag should be treated as\nindentation, and prepended to each line of the Parent before rendering.\n\nThe Block tags' content MUST be a non-whitespace character sequence NOT\ncontaining the current closing delimiter. Each Block tag MUST be followed by\nan End Section tag with the same content within the matching Block tag. This\ntag's content determines the parameter or argument name.\n\nBlock tags may appear both inside and outside of Parent tags. In both cases,\nthey specify a position within the template that can be overridden; it is a\nparameter of the containing template. The template text between the Block tag\nand its matching End Section tag defines the default content to render when\nthe parameter is not overridden from outside.\n\nIn addition, when used inside of a Parent tag, the template text between a\nBlock tag and its matching End Section tag defines content that replaces the\ndefault defined in the Parent template. This content is the argument passed\nto the Parent template.\n\nThe practice of injecting an external template using a Parent tag is referred\nto as inheritance. If the Parent tag includes a Block tag that overrides a\nparameter of the Parent template, this may also be referred to as\nsubstitution.\n\nParent templates are taken from the same namespace as regular Partial\ntemplates and in fact, injecting a regular Partial is exactly equivalent to\ninjecting a Parent without making any substitutions. Parameter and arguments\nnames live in a namespace that is distinct from both Partials and the context.\n", "tests": [ { "name": "Default", diff --git a/specs/~inheritance.yml b/specs/~inheritance.yml index c4fb430..4c60790 100644 --- a/specs/~inheritance.yml +++ b/specs/~inheritance.yml @@ -37,6 +37,11 @@ overview: | to as inheritance. If the Parent tag includes a Block tag that overrides a parameter of the Parent template, this may also be referred to as substitution. + + Parent templates are taken from the same namespace as regular Partial + templates and in fact, injecting a regular Partial is exactly equivalent to + injecting a Parent without making any substitutions. Parameter and arguments + names live in a namespace that is distinct from both Partials and the context. tests: - name: Default desc: Default content should be rendered if the block isn't overridden -- cgit v1.2.1 From 4945a323d2135e857bd38dfcce0fc1b800f59d33 Mon Sep 17 00:00:00 2001 From: Julian Gonggrijp Date: Wed, 21 Apr 2021 13:08:34 +0200 Subject: Process the first three review comments by @bobthecow (#125) --- specs/~inheritance.json | 2 +- specs/~inheritance.yml | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/specs/~inheritance.json b/specs/~inheritance.json index 9453560..fedb34b 100644 --- a/specs/~inheritance.json +++ b/specs/~inheritance.json @@ -1,6 +1,6 @@ { "__ATTN__": "Do not edit this file; changes belong in the appropriate YAML file.", - "overview": "Like partials, Parent tags are used to expand an external template into the\ncurrent template. Contrary to partials, Parent tags may contain optional\narguments delimited by block tags. For this reason, Parent tags may also be\nreferred to as Parametric Partials.\n\nThe Parent tags' content MUST be a non-whitespace character sequence NOT\ncontaining the current closing delimiter; each Parent tag MUST be followed by\nan End Section tag with the same content within the matching Parent tag.\n\nThis tag's content names the Parent template to inject. Set Delimiter tags\nMUST NOT affect the parsing of a Parent template. The Parent MUST be rendered\nagainst the context stack local to the tag. If the named Parent cannot be\nfound, the empty string SHOULD be used instead, as in interpolations.\n\nParent tags SHOULD be treated as standalone when appropriate. If this tag is\nused standalone, any whitespace preceding the tag should be treated as\nindentation, and prepended to each line of the Parent before rendering.\n\nThe Block tags' content MUST be a non-whitespace character sequence NOT\ncontaining the current closing delimiter. Each Block tag MUST be followed by\nan End Section tag with the same content within the matching Block tag. This\ntag's content determines the parameter or argument name.\n\nBlock tags may appear both inside and outside of Parent tags. In both cases,\nthey specify a position within the template that can be overridden; it is a\nparameter of the containing template. The template text between the Block tag\nand its matching End Section tag defines the default content to render when\nthe parameter is not overridden from outside.\n\nIn addition, when used inside of a Parent tag, the template text between a\nBlock tag and its matching End Section tag defines content that replaces the\ndefault defined in the Parent template. This content is the argument passed\nto the Parent template.\n\nThe practice of injecting an external template using a Parent tag is referred\nto as inheritance. If the Parent tag includes a Block tag that overrides a\nparameter of the Parent template, this may also be referred to as\nsubstitution.\n\nParent templates are taken from the same namespace as regular Partial\ntemplates and in fact, injecting a regular Partial is exactly equivalent to\ninjecting a Parent without making any substitutions. Parameter and arguments\nnames live in a namespace that is distinct from both Partials and the context.\n", + "overview": "Like partials, Parent tags are used to expand an external template into the\ncurrent template. Unlike partials, Parent tags may contain optional\narguments delimited by Block tags. For this reason, Parent tags may also be\nreferred to as Parametric Partials.\n\nThe Parent tags' content MUST be a non-whitespace character sequence NOT\ncontaining the current closing delimiter; each Parent tag MUST be followed by\nan End Section tag with the same content within the matching Parent tag.\n\nThis tag's content names the Parent template to inject. Set Delimiter tags\nPreceding a Parent tag MUST NOT affect the parsing of the injected external\ntemplate. The Parent MUST be rendered against the context stack local to the\ntag. If the named Parent cannot be found, the empty string SHOULD be used\ninstead, as in interpolations.\n\nParent tags SHOULD be treated as standalone when appropriate. If this tag is\nused standalone, any whitespace preceding the tag should be treated as\nindentation, and prepended to each line of the Parent before rendering.\n\nThe Block tags' content MUST be a non-whitespace character sequence NOT\ncontaining the current closing delimiter. Each Block tag MUST be followed by\nan End Section tag with the same content within the matching Block tag. This\ntag's content determines the parameter or argument name.\n\nBlock tags may appear both inside and outside of Parent tags. In both cases,\nthey specify a position within the template that can be overridden; it is a\nparameter of the containing template. The template text between the Block tag\nand its matching End Section tag defines the default content to render when\nthe parameter is not overridden from outside.\n\nIn addition, when used inside of a Parent tag, the template text between a\nBlock tag and its matching End Section tag defines content that replaces the\ndefault defined in the Parent template. This content is the argument passed\nto the Parent template.\n\nThe practice of injecting an external template using a Parent tag is referred\nto as inheritance. If the Parent tag includes a Block tag that overrides a\nparameter of the Parent template, this may also be referred to as\nsubstitution.\n\nParent templates are taken from the same namespace as regular Partial\ntemplates and in fact, injecting a regular Partial is exactly equivalent to\ninjecting a Parent without making any substitutions. Parameter and arguments\nnames live in a namespace that is distinct from both Partials and the context.\n", "tests": [ { "name": "Default", diff --git a/specs/~inheritance.yml b/specs/~inheritance.yml index 4c60790..07fa081 100644 --- a/specs/~inheritance.yml +++ b/specs/~inheritance.yml @@ -1,7 +1,7 @@ overview: | Like partials, Parent tags are used to expand an external template into the - current template. Contrary to partials, Parent tags may contain optional - arguments delimited by block tags. For this reason, Parent tags may also be + current template. Unlike partials, Parent tags may contain optional + arguments delimited by Block tags. For this reason, Parent tags may also be referred to as Parametric Partials. The Parent tags' content MUST be a non-whitespace character sequence NOT @@ -9,9 +9,10 @@ overview: | an End Section tag with the same content within the matching Parent tag. This tag's content names the Parent template to inject. Set Delimiter tags - MUST NOT affect the parsing of a Parent template. The Parent MUST be rendered - against the context stack local to the tag. If the named Parent cannot be - found, the empty string SHOULD be used instead, as in interpolations. + Preceding a Parent tag MUST NOT affect the parsing of the injected external + template. The Parent MUST be rendered against the context stack local to the + tag. If the named Parent cannot be found, the empty string SHOULD be used + instead, as in interpolations. Parent tags SHOULD be treated as standalone when appropriate. If this tag is used standalone, any whitespace preceding the tag should be treated as -- cgit v1.2.1