Allow whitespace in filter expression

This commit is contained in:
Niels de Hoog
2015-11-23 15:27:51 +01:00
parent a1a268d5ac
commit aca0a3181d
2 changed files with 7 additions and 1 deletions

View File

@@ -6,7 +6,7 @@ class FilterExpression : Resolvable {
let variable: Variable
init(token: String, parser: TokenParser) throws {
let bits = token.characters.split("|").map(String.init)
let bits = token.characters.split("|").map({ String($0).trim(" ") })
if bits.isEmpty {
filters = []
variable = Variable("")

View File

@@ -30,6 +30,12 @@ describe("template filters") {
try expect(try template.render(context, namespace: namespace)).toThrow(TemplateSyntaxError("No Repeat"))
}
$0.it("allows whitespace in expression") {
let template = Template(templateString: "{{ name | uppercase }}")
let result = try template.render(Context(dictionary: ["name": "kyle"]))
try expect(result) == "KYLE"
}
}