summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Appel <Dan.appel00@gmail.com>2021-05-02 16:19:05 -0700
committerGitHub <noreply@github.com>2021-05-02 16:19:05 -0700
commit84f81d1252d0dd064f672ff4d52d09078826c0cd (patch)
treec7e752e4c61ecdea56908366b5c1d22aa559e173
parent63c0bde1f4e2f8ee26cf2d869dcb0f4fc215646d (diff)
parent300984b04c0c1efafc75f4dcf7f7af5b64952882 (diff)
downloadmustache-spec-84f81d1252d0dd064f672ff4d52d09078826c0cd.tar.gz
Merge pull request #123 from jgonggrijp/null-interpolation
Specify how to interpolate null (#101)
-rw-r--r--specs/interpolation.json27
-rw-r--r--specs/interpolation.yml18
-rw-r--r--specs/inverted.json9
-rw-r--r--specs/inverted.yml6
-rw-r--r--specs/sections.json9
-rw-r--r--specs/sections.yml6
6 files changed, 75 insertions, 0 deletions
diff --git a/specs/interpolation.json b/specs/interpolation.json
index 1718e1c..d422dc3 100644
--- a/specs/interpolation.json
+++ b/specs/interpolation.json
@@ -101,6 +101,33 @@
"expected": "\"1.21 jiggawatts!\""
},
{
+ "name": "Basic Null Interpolation",
+ "desc": "Nulls should interpolate as the empty string.",
+ "data": {
+ "cannot": null
+ },
+ "template": "I ({{cannot}}) be seen!",
+ "expected": "I () be seen!"
+ },
+ {
+ "name": "Triple Mustache Null Interpolation",
+ "desc": "Nulls should interpolate as the empty string.",
+ "data": {
+ "cannot": null
+ },
+ "template": "I ({{{cannot}}}) be seen!",
+ "expected": "I () be seen!"
+ },
+ {
+ "name": "Ampersand Null Interpolation",
+ "desc": "Nulls should interpolate as the empty string.",
+ "data": {
+ "cannot": null
+ },
+ "template": "I ({{&cannot}}) be seen!",
+ "expected": "I () be seen!"
+ },
+ {
"name": "Basic Context Miss Interpolation",
"desc": "Failed context lookups should default to empty strings.",
"data": {
diff --git a/specs/interpolation.yml b/specs/interpolation.yml
index 1b6fff1..9410a30 100644
--- a/specs/interpolation.yml
+++ b/specs/interpolation.yml
@@ -101,6 +101,24 @@ tests:
template: '"{{&power}} jiggawatts!"'
expected: '"1.21 jiggawatts!"'
+ - name: Basic Null Interpolation
+ desc: Nulls should interpolate as the empty string.
+ data: { cannot: null }
+ template: "I ({{cannot}}) be seen!"
+ expected: "I () be seen!"
+
+ - name: Triple Mustache Null Interpolation
+ desc: Nulls should interpolate as the empty string.
+ data: { cannot: null }
+ template: "I ({{{cannot}}}) be seen!"
+ expected: "I () be seen!"
+
+ - name: Ampersand Null Interpolation
+ desc: Nulls should interpolate as the empty string.
+ data: { cannot: null }
+ template: "I ({{&cannot}}) be seen!"
+ expected: "I () be seen!"
+
# Context Misses
- name: Basic Context Miss Interpolation
diff --git a/specs/inverted.json b/specs/inverted.json
index d9a7c15..5e881d1 100644
--- a/specs/inverted.json
+++ b/specs/inverted.json
@@ -21,6 +21,15 @@
"expected": "\"\""
},
{
+ "name": "Null is falsey",
+ "desc": "Null is falsey.",
+ "data": {
+ "null": null
+ },
+ "template": "\"{{^null}}This should be rendered.{{/null}}\"",
+ "expected": "\"This should be rendered.\""
+ },
+ {
"name": "Context",
"desc": "Objects and hashes should behave like truthy values.",
"data": {
diff --git a/specs/inverted.yml b/specs/inverted.yml
index 5f8e2b2..148b3f5 100644
--- a/specs/inverted.yml
+++ b/specs/inverted.yml
@@ -46,6 +46,12 @@ tests:
template: '"{{^boolean}}This should not be rendered.{{/boolean}}"'
expected: '""'
+ - name: Null is falsey
+ desc: Null is falsey.
+ data: { "null": null }
+ template: '"{{^null}}This should be rendered.{{/null}}"'
+ expected: '"This should be rendered."'
+
- name: Context
desc: Objects and hashes should behave like truthy values.
data: { context: { name: 'Joe' } }
diff --git a/specs/sections.json b/specs/sections.json
index 73eb2a4..3acc414 100644
--- a/specs/sections.json
+++ b/specs/sections.json
@@ -21,6 +21,15 @@
"expected": "\"\""
},
{
+ "name": "Null is falsey",
+ "desc": "Null is falsey.",
+ "data": {
+ "null": null
+ },
+ "template": "\"{{#null}}This should not be rendered.{{/null}}\"",
+ "expected": "\"\""
+ },
+ {
"name": "Context",
"desc": "Objects and hashes should be pushed onto the context stack.",
"data": {
diff --git a/specs/sections.yml b/specs/sections.yml
index 40021c0..fdfd799 100644
--- a/specs/sections.yml
+++ b/specs/sections.yml
@@ -47,6 +47,12 @@ tests:
template: '"{{#boolean}}This should not be rendered.{{/boolean}}"'
expected: '""'
+ - name: Null is falsey
+ desc: Null is falsey.
+ data: { "null": null }
+ template: '"{{#null}}This should not be rendered.{{/null}}"'
+ expected: '""'
+
- name: Context
desc: Objects and hashes should be pushed onto the context stack.
data: { context: { name: 'Joe' } }