summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoranomal00us <95467104+anomal00us@users.noreply.github.com>2022-07-18 11:07:52 +0200
committerroot <root@delphi.lan>2022-08-08 21:07:50 +0200
commitb32a4aef1fae82cb08c0b6c8e2e7584ef5ceb12d (patch)
treefe93ae4c7ceee3f09ee11b9e517da295b77dbf31
parent22c3bf1ad7983360e4f20b953cd3ab88d941d5d7 (diff)
downloadmustache-spec-b32a4aef1fae82cb08c0b6c8e2e7584ef5ceb12d.tar.gz
Removing interpolation example and adding JSON spec
Removing interpolation test
-rw-r--r--specs/~dynamic-names.json46
-rw-r--r--specs/~dynamic-names.yml14
2 files changed, 14 insertions, 46 deletions
diff --git a/specs/~dynamic-names.json b/specs/~dynamic-names.json
index 57c1665..03f1c7a 100644
--- a/specs/~dynamic-names.json
+++ b/specs/~dynamic-names.json
@@ -1,17 +1,7 @@
{
- "overview": "Dynamic Names are a special way to dynamically refer to a tag name.\n\nDynamic Names MUST be a non-whitespace character sequence NOT containing\nthe current closing delimiter.\n\nThis tag's content refers to a key in the context whose value will be used in\nplace of the Dynamic Name itself as content of the tag. The name resolution is\nas follows:\n 1) Split the name on periods; the first part is the name to resolve, any\n remaining parts should be retained.\n 2) Walk the context stack from top to bottom, finding the first context\n that is a) a hash containing the name as a key OR b) an object responding\n to a method with the given name.\n 3) If the context is a hash, the data is the value associated with the\n name.\n 4) If the context is an object, the data is the value returned by the\n method with the given name.\n 5) If any name parts were retained in step 1, each should be resolved\n against a context stack containing only the result from the former\n resolution. If any part fails resolution, the result should be considered\n falsey, and should interpolate as the empty string.\nThe resolved data should be coerced into a string before being used as\ncontent.\n\nSet Delimiter tags MUST NOT affect the resolution of a Dynamic Name. The\nDynamic Names MUST be rendered against the context stack local to the tag.\nFailed resolutions of the key (context lookups) should be considered falsey\nand should interpolate as the empty string.\n\nDynamic Names can be combined with every other tag: those tags' content is the\nresolution of the Dynamic Name. Dynamic Names cannot be resolved more than\nonce (Dynamic Names cannot be nested).\n",
+ "overview": "Dynamic Names are a special notation to dynamically determine a tag's content.\n\nDynamic Names MUST be a non-whitespace character sequence NOT containing\nthe current closing delimiter. A Dynamic Name consists of an asterisk,\nfollowed by a dotted name. The latter follows the same notation as in an\nInterpolation tag.\n\nThis tag's content refers to a key in the context whose value will be used in\nplace of the Dynamic Name itself as content of the tag. The name resolution is\nidentical to name resolution in Interpolation tags, as follows:\n 1) Split the name on periods; the first part is the name to resolve, any\n remaining parts should be retained.\n 2) Walk the context stack from top to bottom, finding the first context\n that is a) a hash containing the name as a key OR b) an object responding\n to a method with the given name.\n 3) If the context is a hash, the data is the value associated with the\n name.\n 4) If the context is an object, the data is the value returned by the\n method with the given name.\n 5) If any name parts were retained in step 1, each should be resolved\n against a context stack containing only the result from the former\n resolution. If any part fails resolution, the result should be considered\n falsey, and should interpolate as the empty string.\nThe resolved data should be coerced into a string before being used as\ncontent.\n\nSet Delimiter tags MUST NOT affect the resolution of a Dynamic Name. The\nDynamic Names MUST be resolved against the context stack local to the tag.\nFailed resolution of the dynamic name should result in nothing being rendered.\n\nEngines that implement Dynamic Names MUST support their use in Partial tags.\nIn engines that also implement the optional inheritance spec, Dynamic Names\ninside Parent tags should be supported as well. Dynamic Names cannot be\nresolved more than once (Dynamic Names cannot be nested).\n",
"tests": [
{
- "name": "Basic Behavior - Interpolation",
- "desc": "The asterisk operator is used for dynamic names.",
- "data": {
- "dynamic": "Hello, world!"
- },
- "template": "\"{{*dynamic}}\"",
- "partials": {},
- "expected": "\"Hello, world!\""
- },
- {
"name": "Basic Behavior - Partial",
"desc": "The asterisk operator is used for dynamic partials.",
"data": {
@@ -24,14 +14,6 @@
"expected": "\"Hello, world!\""
},
{
- "name": "Context Misses - Interpolation",
- "desc": "Failed context lookups should be considered falsey.",
- "data": {},
- "template": "\"{{*missing}}\"",
- "partials": {},
- "expected": "\"\""
- },
- {
"name": "Context Misses - Partial",
"desc": "Failed context lookups should be considered falsey.",
"data": {},
@@ -55,12 +37,12 @@
},
{
"name": "Context",
- "desc": "The asterisk operator should operate within the current context.",
+ "desc": "The dynamic partial should operate within the current context.",
"data": {
"text": "Hello, world!",
"example": "partial"
},
- "template": "\"{{*example}}\"",
+ "template": "\"{{>*example}}\"",
"partials": {
"partial": "*{{text}}*"
},
@@ -68,7 +50,7 @@
},
{
"name": "Recursion",
- "desc": "The asterisk operator should properly recurse.",
+ "desc": "Dynamic partials should properly recurse.",
"data": {
"template": "node",
"content": "X",
@@ -79,19 +61,19 @@
}
]
},
- "template": "{{*template}}",
+ "template": "{{>*template}}",
"partials": {
- "node": "{{content}}<{{#nodes}}{{*template}}{{/nodes}}>"
+ "node": "{{content}}<{{#nodes}}{{>*template}}{{/nodes}}>"
},
"expected": "X<Y<>>"
},
{
"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",
+ "desc": "A dynamic partials 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}} |",
+ "template": "| {{>*partial}} |",
"partials": {
"foobar": "\t|\t"
},
@@ -104,7 +86,7 @@
"dynamic": "partial",
"data": "|"
},
- "template": " {{data}} {{* dynamic}}\n",
+ "template": " {{data}} {{>* dynamic}}\n",
"partials": {
"partial": ">\n>"
},
@@ -116,7 +98,7 @@
"data": {
"dynamic": "partial"
},
- "template": "|\r\n{{*dynamic}}\r\n|",
+ "template": "|\r\n{{>*dynamic}}\r\n|",
"partials": {
"partial": ">"
},
@@ -128,7 +110,7 @@
"data": {
"dynamic": "partial"
},
- "template": " {{*dynamic}}\n>",
+ "template": " {{>*dynamic}}\n>",
"partials": {
"partial": ">\n>"
},
@@ -140,7 +122,7 @@
"data": {
"dynamic": "partial"
},
- "template": ">\n {{*dynamic}}",
+ "template": ">\n {{>*dynamic}}",
"partials": {
"partial": ">\n>"
},
@@ -153,7 +135,7 @@
"dynamic": "partial",
"content": "<\n->"
},
- "template": "\\\n {{*dynamic}}\n/\n",
+ "template": "\\\n {{>*dynamic}}\n/\n",
"partials": {
"partial": "|\n{{{content}}}\n|\n"
},
@@ -166,7 +148,7 @@
"dynamic": "partial",
"boolean": true
},
- "template": "|{{* dynamic }}|",
+ "template": "|{{> *dynamic }}|",
"partials": {
"partial": "[]"
},
diff --git a/specs/~dynamic-names.yml b/specs/~dynamic-names.yml
index 3005907..5923b13 100644
--- a/specs/~dynamic-names.yml
+++ b/specs/~dynamic-names.yml
@@ -34,13 +34,6 @@ overview: |
inside Parent tags should be supported as well. Dynamic Names cannot be
resolved more than once (Dynamic Names cannot be nested).
tests:
- - name: Basic Behavior - Interpolation
- desc: The asterisk operator is used for dynamic names.
- data: { dynamic: 'Hello, world!' }
- template: '"{{*dynamic}}"'
- partials: { }
- expected: '"Hello, world!"'
-
- name: Basic Behavior - Partial
desc: The asterisk operator is used for dynamic partials.
data: { dynamic: 'content' }
@@ -48,13 +41,6 @@ tests:
partials: { content: 'Hello, world!' }
expected: '"Hello, world!"'
- - name: Context Misses - Interpolation
- desc: Failed context lookups should be considered falsey.
- data: { }
- template: '"{{*missing}}"'
- partials: { }
- expected: '""'
-
- name: Context Misses - Partial
desc: Failed context lookups should be considered falsey.
data: { }