diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bd4458..c123c4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,7 +40,7 @@ - `for` block now allows you to iterate over array of tuples or dictionaries. ```html+django - {% for key, value in thing %} + {% for key,value in thing %}
  • {{ key }}: {{ value }}
  • {% endfor %} ``` diff --git a/Tests/StencilTests/ForNodeSpec.swift b/Tests/StencilTests/ForNodeSpec.swift index df77f66..8804f0b 100644 --- a/Tests/StencilTests/ForNodeSpec.swift +++ b/Tests/StencilTests/ForNodeSpec.swift @@ -127,6 +127,18 @@ func testForNode() { try expect(result) == fixture } + $0.it("can iterate over dictionary") { + let templateString = "{% for key,value in dict %}" + + "{{ key }}: {{ value }}\n" + + "{% endfor %}\n" + + let template = Template(templateString: templateString) + let result = try template.render(context) + + let fixture = "one: I\ntwo: II\n\n" + try expect(result) == fixture + } + $0.it("renders supports iterating over dictionary") { let nodes: [NodeType] = [VariableNode(variable: "key")] let emptyNodes: [NodeType] = [TextNode(text: "empty")]