summaryrefslogtreecommitdiff
path: root/specs/~dynamic-names.json
diff options
context:
space:
mode:
authoranomal00us <95467104+anomal00us@users.noreply.github.com>2022-07-20 16:47:05 +0200
committerroot <root@delphi.lan>2022-08-08 21:07:58 +0200
commitc1449c20794609c21794d163a17b97370af67b92 (patch)
tree1a95bb4ff3df1b719b073cd8ccdde46dbb53e7e2 /specs/~dynamic-names.json
parentb32a4aef1fae82cb08c0b6c8e2e7584ef5ceb12d (diff)
downloadmustache-spec-c1449c20794609c21794d163a17b97370af67b92.tar.gz
Dotted names and context stacking tests
Diffstat (limited to 'specs/~dynamic-names.json')
-rw-r--r--specs/~dynamic-names.json109
1 files changed, 109 insertions, 0 deletions
diff --git a/specs/~dynamic-names.json b/specs/~dynamic-names.json
index 03f1c7a..c6aade6 100644
--- a/specs/~dynamic-names.json
+++ b/specs/~dynamic-names.json
@@ -49,6 +49,115 @@
"expected": "\"*Hello, world!*\""
},
{
+ "name": "Dotted Names",
+ "desc": "The dynamic partial should operate within the current context.",
+ "data": {
+ "text": "Hello, world!",
+ "foo": {
+ "bar": {
+ "baz": "partial"
+ }
+ }
+ },
+ "template": "\"{{>*foo.bar.baz}}\"",
+ "partials": {
+ "partial": "*{{text}}*"
+ },
+ "expected": "\"*Hello, world!*\""
+ },
+ {
+ "name": "Dotted Names - Failed Lookup",
+ "desc": "The dynamic partial should operate within the current context.",
+ "data": {
+ "text": "Hello, world!",
+ "foo": "test",
+ "test": {
+ "bar": {
+ "baz": "partial"
+ }
+ }
+ },
+ "template": "\"{{>*foo.bar.baz}}\"",
+ "partials": {
+ "partial": "*{{text}}*"
+ },
+ "expected": "\"\""
+ },
+ {
+ "name": "Dotted Names - Failed Lookup",
+ "desc": "The dynamic partial should operate within the current context.",
+ "data": {
+ "foo": {
+ "text": "Hello, world!",
+ "bar": {
+ "baz": "partial"
+ }
+ }
+ },
+ "template": "\"{{>*foo.bar.baz}}\"",
+ "partials": {
+ "partial": "*{{text}}*"
+ },
+ "expected": "\"**\""
+ },
+ {
+ "name": "Dotted names - Context Stacking",
+ "desc": "Dotted names should not push a new frame on the context stack.",
+ "data": {
+ "section1": {
+ "value": "section1"
+ },
+ "section2": {
+ "dynamic": "partial",
+ "value": "section2"
+ }
+ },
+ "template": "{{#section1}}{{>*section2.dynamic}}{{/section1}}",
+ "partials": {
+ "partial": "{{value}}"
+ },
+ "expected": "\"section1\""
+ },
+ {
+ "name": "Dotted names - Context Stacking Under Repetition",
+ "desc": "Dotted names should not push a new frame on the context stack.",
+ "data": {
+ "value": "test",
+ "section1": [
+ 1,
+ 2
+ ],
+ "section2": {
+ "dynamic": "partial",
+ "value": "section2"
+ }
+ },
+ "template": "{{#section1}}{{>*section2.dynamic}}{{/section1}}",
+ "partials": {
+ "partial": "{{value}}"
+ },
+ "expected": "testtest"
+ },
+ {
+ "name": "Dotted names - Context Stacking Failed Lookup",
+ "desc": "Dotted names should resolve against the proper context stack.",
+ "data": {
+ "section1": [
+ 1,
+ 2
+ ],
+ "section2": {
+ "dynamic": "partial",
+ "value": "section2"
+ }
+ },
+ "template": "{{#section1}}{{>*section2.dynamic}}{{/section1}}",
+ "partials": {
+ "partial": "\"{{value}}\""
+ },
+ "expected": "\"\""
+ },
+ {
"name": "Recursion",
"desc": "Dynamic partials should properly recurse.",
"data": {