fix(default): Check for wrapped nil in filter (#162)

This commit is contained in:
Ilya Puchka
2017-12-24 20:11:46 +01:00
committed by Kyle Fuller
parent 9357df35d1
commit 1223efbc7e
3 changed files with 11 additions and 1 deletions

View File

@@ -136,6 +136,14 @@ func testFilter() {
let result = try template.render(Context(dictionary: [:]))
try expect(result) == "Hello World"
}
$0.it("checks for underlying nil value correctly") {
let template = Template(templateString: "Hello {{ user.name|default:\"anonymous\" }}")
let nilName: String? = nil
let user: [String: Any?] = ["name": nilName]
let result = try template.render(Context(dictionary: ["user": user]))
try expect(result) == "Hello anonymous"
}
}
describe("join filter") {