summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Gonggrijp <dev@juliangonggrijp.com>2021-04-23 12:50:36 +0200
committerJulian Gonggrijp <dev@juliangonggrijp.com>2021-04-23 12:50:36 +0200
commit300984b04c0c1efafc75f4dcf7f7af5b64952882 (patch)
treec4ed164d059b68e929948dd36dfeaaa572f7a400
parentaad6725ea0ca928c50bde433a953fa094d1fd5e7 (diff)
downloadmustache-spec-300984b04c0c1efafc75f4dcf7f7af5b64952882.tar.gz
Specify null handling in (inverted) sections (@Danappelxx comment #123)
-rw-r--r--specs/inverted.json9
-rw-r--r--specs/inverted.yml6
-rw-r--r--specs/sections.json9
-rw-r--r--specs/sections.yml6
4 files changed, 30 insertions, 0 deletions
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' } }