From 300984b04c0c1efafc75f4dcf7f7af5b64952882 Mon Sep 17 00:00:00 2001 From: Julian Gonggrijp Date: Fri, 23 Apr 2021 12:50:36 +0200 Subject: Specify null handling in (inverted) sections (@Danappelxx comment #123) --- specs/inverted.json | 9 +++++++++ specs/inverted.yml | 6 ++++++ specs/sections.json | 9 +++++++++ specs/sections.yml | 6 ++++++ 4 files changed, 30 insertions(+) diff --git a/specs/inverted.json b/specs/inverted.json index d9a7c15..5e881d1 100644 --- a/specs/inverted.json +++ b/specs/inverted.json @@ -20,6 +20,15 @@ "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.", 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 @@ -20,6 +20,15 @@ "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.", 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' } } -- cgit v1.2.1