diff options
Diffstat (limited to 'docs/templates.txt')
| -rw-r--r-- | docs/templates.txt | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/docs/templates.txt b/docs/templates.txt index c191b409f4..5f397c5a60 100644 --- a/docs/templates.txt +++ b/docs/templates.txt @@ -454,8 +454,12 @@ displayed by the ``{{ athlete_list|length }}`` variable. As you can see, the ``if`` tag can take an option ``{% else %}`` clause that will be displayed if the test fails. -``if`` tags may use ``or`` or ``not`` to test a number of variables or to negate -a given variable:: +``if`` tags may use ``and``, ``or`` or ``not`` to test a number of variables or +to negate a given variable:: + + {% if athlete_list and coach_list %} + Both athletes and coaches are available. + {% endif %} {% if not athlete_list %} There are no athletes. @@ -468,16 +472,24 @@ a given variable:: {% if not athlete_list or coach_list %} There are no athletes or there are some coaches (OK, so writing English translations of boolean logic sounds - stupid; it's not my fault). + stupid; it's not our fault). + {% endif %} + + {% if athlete_list and not coach_list %} + There are some athletes and absolutely no coaches. {% endif %} -For simplicity, ``if`` tags do not allow ``and`` clauses; use nested ``if`` -tags instead:: +``if`` tags don't allow ``and`` and ``or`` clauses within the same tag, because +the order of logic would be ambiguous. For example, this is invalid:: + + {% if athlete_list and coach_list or cheerleader_list %} + +If you need to combine ``and`` and ``or`` to do advanced logic, just use nested +``if`` tags. For example:: {% if athlete_list %} - {% if coach_list %} - Number of athletes: {{ athlete_list|length }}. - Number of coaches: {{ coach_list|length }}. + {% if coach_list or cheerleader_list %} + We have athletes, and either coaches or cheerleaders! {% endif %} {% endif %} @@ -754,6 +766,8 @@ The argument tells which template bit to output: ``closeblock`` ``%}`` ``openvariable`` ``{{`` ``closevariable`` ``}}`` + ``openbrace`` ``{`` + ``closebrace`` ``}`` ================== ======= widthratio |
