import Stencil
let aNilString: String? = nil
var testContext: [String: Any] = [
"notNil": "I'm Not Nil" as Any,
"nil": aNilString as Any
]
testContext["subDictionary"] = testContext
let templateString = """
{{ notNil|default:"It's Nil" }}
{{ nil|default:"It's Nil" }}
{{ subDictionary.notNil|default:"It's Nil" }}
{{ subDictionary.nil|default:"It's Nil" }}
"""
let template = Template(templateString: templateString)
let result = try template.render(testContext)
print(result)
Expected result:
I'm Not Nil
It's Nil
I'm Not Nil
It's Nil
Actual result:
I'm Not Nil
It's Nil
I'm Not Nil
Here's a full project you can clone and run to see this happening in real time. This is a distillation of behavior I'm seeing happening on a "real" project (a Kitura site).
Other filters such as uppercase seem to work fine on dictionary elements, though I haven't tested all of them.
Expected result:
Actual result:
Here's a full project you can clone and run to see this happening in real time. This is a distillation of behavior I'm seeing happening on a "real" project (a Kitura site).
Other filters such as
uppercase
seem to work fine on dictionary elements, though I haven't tested all of them.