Created on 15 July 2024, 5 months ago

Problem/Motivation

Twig, Jinja, Nunjucks... allow to replace this annoying syntax;

{% if foo %}
{% for item in foo %}
{{ item }}
{% endfor %}
{% else %}
  No foo
{% endif %}

by this compact, elegant, syntax:

{% for item in foo %}
{{ item }}
{% else %}
  No foo
{% endfor %}

More generally, without considering the ELSE part, it seems this:

{% if foo %}
{% for item in foo %}
{{ item }}
{% endfor %}
{% endif %}
{% if foo is whatever condition %}
{% for item in foo %}
{{ item }}
{% endfor %}
{% endif %}

can also be written like this:

{% for item in foo %}
{{ item }}
{% endfor %}

Proposed resolution

It would be nice to promote it as a good practice.

Is it easy to test in ui_patterns_devel's component validator if a IF block has empty text nodes and a FOR block as only child nodes?

Feature request
Status

Active

Version

2.0

Component

UI Patterns Devel [2.x only]

Created by

🇫🇷France pdureau Paris

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024