stencilproject / Stencil

Stencil is a simple and powerful template language for Swift.
https://stencil.fuller.li
BSD 2-Clause "Simplified" License
2.34k stars 223 forks source link

For loop improvements #163

Closed ilyapuchka closed 6 years ago

ilyapuchka commented 6 years ago

This PR contains several improvements for for tag:

{% for key, value in dict %}
{% for index, value in array %}
{{ index }}: {{ array.index }}
{% endfor %}
{% for key in dict %}
{{ key }}: {{ dict.key }}
{% endfor %}
{% for index, value in array %}
{{ index }}: {{ value }}
{% endfor %}
{% for label, value in tuple %}
{{ label }}: {{ value }}
{% endfor %}
{% for label in tuple %}
{{ label }}: {{ tuple.label }}
{% endfor %}
{% for item in items %}
  {{ item }}
  {% if condition %}{% break %}{% endif %}
{% endfor %}
ilyapuchka commented 6 years ago

@kylef I'll break this into smaller separate prs so that it's easier for you to review, I expected it to be smaller, but it grew fast =))