docs(for): document that dictionary for doesn't support space

This commit is contained in:
Yonas Kolb
2017-05-02 14:53:55 +08:00
committed by Kyle Fuller
parent 14bac03990
commit bf4be38377
2 changed files with 13 additions and 1 deletions

View File

@@ -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 %}
<li>{{ key }}: {{ value }}</li>
{% endfor %}
```

View File

@@ -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")]