Skip to content

Commit

Permalink
Merge pull request #13 from vapor/if-nullability
Browse files Browse the repository at this point in the history
evaluate non-nil as true in if tag
  • Loading branch information
loganwright authored Sep 1, 2016
2 parents 491436e + 28d50c1 commit 73be197
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Sources/Leaf/Tag/Models/If.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

0 comments on commit 73be197

Please sign in to comment.