From a15b333b08e3f0db5a62baf6d6d55f364f380a5a Mon Sep 17 00:00:00 2001 From: anomal00us <95467104+anomal00us@users.noreply.github.com> Date: Mon, 6 Dec 2021 14:43:18 +0100 Subject: Renaming dynamic partials spec --- specs/dynamic.json | 147 ---------------------------------------- specs/dynamic.yml | 140 -------------------------------------- specs/~dynamic-partials.json | 157 +++++++++++++++++++++++++++++++++++++++++++ specs/~dynamic-partials.yml | 140 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 297 insertions(+), 287 deletions(-) delete mode 100644 specs/dynamic.json delete mode 100644 specs/dynamic.yml create mode 100644 specs/~dynamic-partials.json create mode 100644 specs/~dynamic-partials.yml diff --git a/specs/dynamic.json b/specs/dynamic.json deleted file mode 100644 index 8fa5cf4..0000000 --- a/specs/dynamic.json +++ /dev/null @@ -1,147 +0,0 @@ -{ - "overview": "Dynamic partials tags are used to dynamically expand an external template into\nthe current template.\n\nThe tag's content MUST be a non-whitespace character sequence NOT containing\nthe current closing delimiter.\n\nThis tag's content names a key in the context whose value is the name of the\npartial that will be loaded. If the dynamically named partial cannot be found,\nthe empty string SHOULD be used instead, as in interpolations. Set Delimiter\ntags MUST NOT affect the parsing of a partial. The partial MUST be rendered\nagainst the context stack local to the tag. Failed resolutions of the key\n(context lookups) should be considered falsey and should interpolate as the\nempty string. If the partial, whose name is retrieved from the context stack,\ncannot be found, the empty string SHOULD be used instead, as in\ninterpolations.\n\nDynamic partial tags SHOULD be treated as standalone when appropriate. If\nthis tag is used standalone, any whitespace preceding the tag should treated\nas indentation, and prepended to each line of the partial before rendering.\n", - "tests": [ - { - "name": "Basic Behavior", - "desc": "The asterisk operator is used for dynamic partials.", - "data": { - "dynamic": "content" - }, - "template": "\"{{*dynamic}}\"", - "partials": { - "content": "Hello, world!" - }, - "expected": "\"Hello, world!\"" - }, - { - "name": "Context Misses", - "desc": "Failed context lookups should be considered falsey.", - "data": {}, - "template": "\"{{*missing}}\"", - "partials": {}, - "expected": "\"\"" - }, - { - "name": "Failed Lookup", - "desc": "The empty string should be used when the named partial is not found.", - "data": { - "dynamic": "content" - }, - "template": "\"{{*dynamic}}\"", - "partials": { - "foobar": "Hello, world!" - }, - "expected": "\"\"" - }, - { - "name": "Context", - "desc": "The asterisk operator should operate within the current context.", - "data": { - "text": "Hello, world!", - "example": "partial" - }, - "template": "\"{{*example}}\"", - "partials": { - "partial": "*{{text}}*" - }, - "expected": "\"*Hello, world!*\"" - }, - { - "name": "Recursion", - "desc": "The asterisk operator should properly recurse.", - "data": "{\n template: 'node',\n content: 'X',\n nodes: [ { content: 'Y', nodes: [] } ]\n}\n", - "template": "{{*template}}", - "partials": { - "node": "{{content}}<{{#nodes}}{{>node}}{{/nodes}}>" - }, - "expected": "X>" - }, - { - "name": "Surrounding Whitespace", - "desc": "The asterisk operator should not alter surrounding whitespace.", - "data": { - "partial": "foobar" - }, - "template": "| {{*partial}} |", - "partials": { - "foobar": "\t|\t" - }, - "expected": "| \t|\t |" - }, - { - "name": "Inline Indentation", - "desc": "Whitespace should be left untouched.", - "data": { - "dynamic": "partial", - "data": "|" - }, - "template": " {{data}} {{* partial}}\n", - "partials": { - "partial": ">\n>" - }, - "expected": " | >\n>\n" - }, - { - "name": "Standalone Line Endings", - "desc": "\"\\r\\n\" should be considered a newline for standalone tags.", - "data": { - "dynamic": "partial" - }, - "template": "|\r\n{{*dynamic}}\r\n|", - "partials": { - "partial": ">" - }, - "expected": "|\r\n>|" - }, - { - "name": "Standalone Without Previous Line", - "desc": "Standalone tags should not require a newline to precede them.", - "data": { - "dynamic": "partial" - }, - "template": " {{*dynamic}}\n>", - "partials": { - "partial": ">\n>" - }, - "expected": " >\n >>" - }, - { - "name": "Standalone Without Newline", - "desc": "Standalone tags should not require a newline to follow them.", - "data": { - "dynamic": "partial" - }, - "template": ">\n {{*dynamic}}", - "partials": { - "partial": ">\n>" - }, - "expected": ">\n >\n >" - }, - { - "name": "Standalone Indentation", - "desc": "Each line of the partial should be indented before rendering.", - "data": { - "dynamic": "partial", - "content": "<\n->" - }, - "template": "\\\n {{*dynamic}}\n/\n", - "partials": { - "partial": "|\n{{{content}}}\n|\n" - }, - "expected": "\\\n |\n <\n->\n |\n/\n" - }, - { - "name": "Padding Whitespace", - "desc": "Superfluous in-tag whitespace should be ignored.", - "data": { - "dynamic": "partial", - "boolean": true - }, - "template": "|{{* dynamic }}|", - "partials": { - "partial": "[]" - }, - "expected": "|[]|" - } - ] -} diff --git a/specs/dynamic.yml b/specs/dynamic.yml deleted file mode 100644 index c61113e..0000000 --- a/specs/dynamic.yml +++ /dev/null @@ -1,140 +0,0 @@ -overview: | - Dynamic partials tags are used to dynamically expand an external template into - the current template. - - The tag's content MUST be a non-whitespace character sequence NOT containing - the current closing delimiter. - - This tag's content names a key in the context whose value is the name of the - partial that will be loaded. If the dynamically named partial cannot be found, - the empty string SHOULD be used instead, as in interpolations. Set Delimiter - tags MUST NOT affect the parsing of a partial. The partial MUST be rendered - against the context stack local to the tag. Failed resolutions of the key - (context lookups) should be considered falsey and should interpolate as the - empty string. If the partial, whose name is retrieved from the context stack, - cannot be found, the empty string SHOULD be used instead, as in - interpolations. - - Dynamic partial tags SHOULD be treated as standalone when appropriate. If - this tag is used standalone, any whitespace preceding the tag should treated - as indentation, and prepended to each line of the partial before rendering: - whitespace handling around dynamic partials SHOULD be identical to whitespace - handling around static (normal) partials. -tests: - - name: Basic Behavior - desc: The asterisk operator is used for dynamic partials. - data: { dynamic: 'content' } - template: '"{{*dynamic}}"' - partials: { content: 'Hello, world!' } - expected: '"Hello, world!"' - - - name: Context Misses - desc: Failed context lookups should be considered falsey. - data: { } - template: '"{{*missing}}"' - partials: { } - expected: '""' - - - name: Context Misses Again - desc: Failed context lookups should be considered falsey. - data: { } - template: '"{{*missing}}"' - partials: { missing: 'Hello, world!' } - expected: '""' - - - name: Failed Lookup - desc: The empty string should be used when the named partial is not found. - data: { dynamic: 'content' } - template: '"{{*dynamic}}"' - partials: { foobar: 'Hello, world!' } - expected: '""' - - - name: Context - desc: The asterisk operator should operate within the current context. - data: { text: 'Hello, world!', example: 'partial' } - template: '"{{*example}}"' - partials: { partial: '*{{text}}*' } - expected: '"*Hello, world!*"' - - - name: Recursion - desc: The asterisk operator should properly recurse. - data: | - { - template: 'node', - content: 'X', - nodes: [ { content: 'Y', nodes: [] } ] - } - template: '{{*template}}' - partials: { node: '{{content}}<{{#nodes}}{{*template}}{{/nodes}}>' } - expected: 'X>' - - # Whitespace Sensitivity - - - name: Surrounding Whitespace - desc: | - The asterisk operator should not alter surrounding whitespace; any - whitespace preceding the tag should treated as indentation while any - whitepsace succeding the tag should be left untouched. - data: { partial: 'foobar' } - template: '| {{*partial}} |' - partials: { foobar: "\t|\t" } - expected: "| \t|\t |" - - - name: Inline Indentation - desc: | - Whitespace should be left untouched: whitespaces preceding the tag - should be treated as indentation. - data: { dynamic: 'partial', data: '|' } - template: " {{data}} {{* dynamic}}\n" - partials: { partial: ">\n>" } - expected: " | >\n>\n" - - - name: Standalone Line Endings - desc: '"\r\n" should be considered a newline for standalone tags.' - data: { dynamic: 'partial' } - template: "|\r\n{{*dynamic}}\r\n|" - partials: { partial: ">" } - expected: "|\r\n>|" - - - name: Standalone Without Previous Line - desc: Standalone tags should not require a newline to precede them. - data: { dynamic: 'partial' } - template: " {{*dynamic}}\n>" - partials: { partial: ">\n>"} - expected: " >\n >>" - - - name: Standalone Without Newline - desc: Standalone tags should not require a newline to follow them. - data: { dynamic: 'partial' } - template: ">\n {{*dynamic}}" - partials: { partial: ">\n>" } - expected: ">\n >\n >" - - - name: Standalone Indentation - desc: Each line of the partial should be indented before rendering. - data: { dynamic: 'partial', content: "<\n->" } - template: | - \ - {{*dynamic}} - / - partials: - partial: | - | - {{{content}}} - | - expected: | - \ - | - < - -> - | - / - - # Whitespace Insensitivity - - - name: Padding Whitespace - desc: Superfluous in-tag whitespace should be ignored. - data: { dynamic: 'partial', boolean: true } - template: "|{{* dynamic }}|" - partials: { partial: "[]" } - expected: '|[]|' diff --git a/specs/~dynamic-partials.json b/specs/~dynamic-partials.json new file mode 100644 index 0000000..f260a15 --- /dev/null +++ b/specs/~dynamic-partials.json @@ -0,0 +1,157 @@ +{ + "overview": "Dynamic partials tags are used to dynamically expand an external template into\nthe current template.\n\nThe tag's content MUST be a non-whitespace character sequence NOT containing\nthe current closing delimiter.\n\nThis tag's content names a key in the context whose value is the name of the\npartial that will be loaded. If the dynamically named partial cannot be found,\nthe empty string SHOULD be used instead, as in interpolations. Set Delimiter\ntags MUST NOT affect the parsing of a partial. The partial MUST be rendered\nagainst the context stack local to the tag. Failed resolutions of the key\n(context lookups) should be considered falsey and should interpolate as the\nempty string. If the partial, whose name is retrieved from the context stack,\ncannot be found, the empty string SHOULD be used instead, as in\ninterpolations.\n\nDynamic partial tags SHOULD be treated as standalone when appropriate. If\nthis tag is used standalone, any whitespace preceding the tag should treated\nas indentation, and prepended to each line of the partial before rendering:\nwhitespace handling around dynamic partials SHOULD be identical to whitespace\nhandling around static (normal) partials.\n", + "tests": [ + { + "name": "Basic Behavior", + "desc": "The asterisk operator is used for dynamic partials.", + "data": { + "dynamic": "content" + }, + "template": "\"{{*dynamic}}\"", + "partials": { + "content": "Hello, world!" + }, + "expected": "\"Hello, world!\"" + }, + { + "name": "Context Misses", + "desc": "Failed context lookups should be considered falsey.", + "data": {}, + "template": "\"{{*missing}}\"", + "partials": {}, + "expected": "\"\"" + }, + { + "name": "Context Misses Again", + "desc": "Failed context lookups should be considered falsey.", + "data": {}, + "template": "\"{{*missing}}\"", + "partials": { + "missing": "Hello, world!" + }, + "expected": "\"\"" + }, + { + "name": "Failed Lookup", + "desc": "The empty string should be used when the named partial is not found.", + "data": { + "dynamic": "content" + }, + "template": "\"{{*dynamic}}\"", + "partials": { + "foobar": "Hello, world!" + }, + "expected": "\"\"" + }, + { + "name": "Context", + "desc": "The asterisk operator should operate within the current context.", + "data": { + "text": "Hello, world!", + "example": "partial" + }, + "template": "\"{{*example}}\"", + "partials": { + "partial": "*{{text}}*" + }, + "expected": "\"*Hello, world!*\"" + }, + { + "name": "Recursion", + "desc": "The asterisk operator should properly recurse.", + "data": "{\n template: 'node',\n content: 'X',\n nodes: [ { content: 'Y', nodes: [] } ]\n}\n", + "template": "{{*template}}", + "partials": { + "node": "{{content}}<{{#nodes}}{{*template}}{{/nodes}}>" + }, + "expected": "X>" + }, + { + "name": "Surrounding Whitespace", + "desc": "The asterisk operator should not alter surrounding whitespace; any\nwhitespace preceding the tag should treated as indentation while any\nwhitepsace succeding the tag should be left untouched.\n", + "data": { + "partial": "foobar" + }, + "template": "| {{*partial}} |", + "partials": { + "foobar": "\t|\t" + }, + "expected": "| \t|\t |" + }, + { + "name": "Inline Indentation", + "desc": "Whitespace should be left untouched: whitespaces preceding the tag\nshould be treated as indentation.\n", + "data": { + "dynamic": "partial", + "data": "|" + }, + "template": " {{data}} {{* dynamic}}\n", + "partials": { + "partial": ">\n>" + }, + "expected": " | >\n>\n" + }, + { + "name": "Standalone Line Endings", + "desc": "\"\\r\\n\" should be considered a newline for standalone tags.", + "data": { + "dynamic": "partial" + }, + "template": "|\r\n{{*dynamic}}\r\n|", + "partials": { + "partial": ">" + }, + "expected": "|\r\n>|" + }, + { + "name": "Standalone Without Previous Line", + "desc": "Standalone tags should not require a newline to precede them.", + "data": { + "dynamic": "partial" + }, + "template": " {{*dynamic}}\n>", + "partials": { + "partial": ">\n>" + }, + "expected": " >\n >>" + }, + { + "name": "Standalone Without Newline", + "desc": "Standalone tags should not require a newline to follow them.", + "data": { + "dynamic": "partial" + }, + "template": ">\n {{*dynamic}}", + "partials": { + "partial": ">\n>" + }, + "expected": ">\n >\n >" + }, + { + "name": "Standalone Indentation", + "desc": "Each line of the partial should be indented before rendering.", + "data": { + "dynamic": "partial", + "content": "<\n->" + }, + "template": "\\\n {{*dynamic}}\n/\n", + "partials": { + "partial": "|\n{{{content}}}\n|\n" + }, + "expected": "\\\n |\n <\n->\n |\n/\n" + }, + { + "name": "Padding Whitespace", + "desc": "Superfluous in-tag whitespace should be ignored.", + "data": { + "dynamic": "partial", + "boolean": true + }, + "template": "|{{* dynamic }}|", + "partials": { + "partial": "[]" + }, + "expected": "|[]|" + } + ] +} diff --git a/specs/~dynamic-partials.yml b/specs/~dynamic-partials.yml new file mode 100644 index 0000000..c61113e --- /dev/null +++ b/specs/~dynamic-partials.yml @@ -0,0 +1,140 @@ +overview: | + Dynamic partials tags are used to dynamically expand an external template into + the current template. + + The tag's content MUST be a non-whitespace character sequence NOT containing + the current closing delimiter. + + This tag's content names a key in the context whose value is the name of the + partial that will be loaded. If the dynamically named partial cannot be found, + the empty string SHOULD be used instead, as in interpolations. Set Delimiter + tags MUST NOT affect the parsing of a partial. The partial MUST be rendered + against the context stack local to the tag. Failed resolutions of the key + (context lookups) should be considered falsey and should interpolate as the + empty string. If the partial, whose name is retrieved from the context stack, + cannot be found, the empty string SHOULD be used instead, as in + interpolations. + + Dynamic partial tags SHOULD be treated as standalone when appropriate. If + this tag is used standalone, any whitespace preceding the tag should treated + as indentation, and prepended to each line of the partial before rendering: + whitespace handling around dynamic partials SHOULD be identical to whitespace + handling around static (normal) partials. +tests: + - name: Basic Behavior + desc: The asterisk operator is used for dynamic partials. + data: { dynamic: 'content' } + template: '"{{*dynamic}}"' + partials: { content: 'Hello, world!' } + expected: '"Hello, world!"' + + - name: Context Misses + desc: Failed context lookups should be considered falsey. + data: { } + template: '"{{*missing}}"' + partials: { } + expected: '""' + + - name: Context Misses Again + desc: Failed context lookups should be considered falsey. + data: { } + template: '"{{*missing}}"' + partials: { missing: 'Hello, world!' } + expected: '""' + + - name: Failed Lookup + desc: The empty string should be used when the named partial is not found. + data: { dynamic: 'content' } + template: '"{{*dynamic}}"' + partials: { foobar: 'Hello, world!' } + expected: '""' + + - name: Context + desc: The asterisk operator should operate within the current context. + data: { text: 'Hello, world!', example: 'partial' } + template: '"{{*example}}"' + partials: { partial: '*{{text}}*' } + expected: '"*Hello, world!*"' + + - name: Recursion + desc: The asterisk operator should properly recurse. + data: | + { + template: 'node', + content: 'X', + nodes: [ { content: 'Y', nodes: [] } ] + } + template: '{{*template}}' + partials: { node: '{{content}}<{{#nodes}}{{*template}}{{/nodes}}>' } + expected: 'X>' + + # Whitespace Sensitivity + + - name: Surrounding Whitespace + desc: | + The asterisk operator should not alter surrounding whitespace; any + whitespace preceding the tag should treated as indentation while any + whitepsace succeding the tag should be left untouched. + data: { partial: 'foobar' } + template: '| {{*partial}} |' + partials: { foobar: "\t|\t" } + expected: "| \t|\t |" + + - name: Inline Indentation + desc: | + Whitespace should be left untouched: whitespaces preceding the tag + should be treated as indentation. + data: { dynamic: 'partial', data: '|' } + template: " {{data}} {{* dynamic}}\n" + partials: { partial: ">\n>" } + expected: " | >\n>\n" + + - name: Standalone Line Endings + desc: '"\r\n" should be considered a newline for standalone tags.' + data: { dynamic: 'partial' } + template: "|\r\n{{*dynamic}}\r\n|" + partials: { partial: ">" } + expected: "|\r\n>|" + + - name: Standalone Without Previous Line + desc: Standalone tags should not require a newline to precede them. + data: { dynamic: 'partial' } + template: " {{*dynamic}}\n>" + partials: { partial: ">\n>"} + expected: " >\n >>" + + - name: Standalone Without Newline + desc: Standalone tags should not require a newline to follow them. + data: { dynamic: 'partial' } + template: ">\n {{*dynamic}}" + partials: { partial: ">\n>" } + expected: ">\n >\n >" + + - name: Standalone Indentation + desc: Each line of the partial should be indented before rendering. + data: { dynamic: 'partial', content: "<\n->" } + template: | + \ + {{*dynamic}} + / + partials: + partial: | + | + {{{content}}} + | + expected: | + \ + | + < + -> + | + / + + # Whitespace Insensitivity + + - name: Padding Whitespace + desc: Superfluous in-tag whitespace should be ignored. + data: { dynamic: 'partial', boolean: true } + template: "|{{* dynamic }}|" + partials: { partial: "[]" } + expected: '|[]|' -- cgit v1.2.1