feat: added split fitler (#187)

This commit is contained in:
Ilya Puchka
2018-01-22 01:49:32 +01:00
committed by Kyle Fuller
parent 2e80f70f67
commit c30597457f
4 changed files with 31 additions and 0 deletions

View File

@@ -183,4 +183,20 @@ func testFilter() {
try expect(result) == "OneTwo"
}
}
describe("split filter") {
let template = Template(templateString: "{{ value|split:\", \" }}")
$0.it("split a string into array") {
let result = try template.render(Context(dictionary: ["value": "One, Two"]))
try expect(result) == "[\"One\", \"Two\"]"
}
$0.it("can split without arguments") {
let template = Template(templateString: "{{ value|split }}")
let result = try template.render(Context(dictionary: ["value": "One, Two"]))
try expect(result) == "[\"One,\", \"Two\"]"
}
}
}