From 28d50c190f9e399f0fe5cb142509f24dd36bc76b Mon Sep 17 00:00:00 2001 From: Logan Wright Date: Thu, 1 Sep 2016 11:58:08 -0400 Subject: [PATCH] evaluate non-nil as true in if tag --- Sources/Leaf/Tag/Models/If.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sources/Leaf/Tag/Models/If.swift b/Sources/Leaf/Tag/Models/If.swift index de69045..6120104 100644 --- a/Sources/Leaf/Tag/Models/If.swift +++ b/Sources/Leaf/Tag/Models/If.swift @@ -20,6 +20,9 @@ public final class If: Tag { tagTemplate: TagTemplate, arguments: [Argument], value: Node?) -> Bool { - return arguments.first?.value?.bool == true + guard let value = arguments.first?.value else { return false } + // Existence of bool, evaluate bool. Otherwise, not-nil returns true. + guard let bool = value.bool else { return true } + return bool } }