Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document chained pow order #1541

Merged
merged 1 commit into from Nov 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 13 additions & 2 deletions docs/templates.rst
Expand Up @@ -1344,8 +1344,19 @@ but exists for completeness' sake. The following operators are supported:
``{{ '=' * 80 }}`` would print a bar of 80 equal signs.

``**``
Raise the left operand to the power of the right operand. ``{{ 2**3 }}``
would return ``8``.
Raise the left operand to the power of the right operand.
``{{ 2**3 }}`` would return ``8``.

Unlike Python, chained pow is evaluated left to right.
``{{ 3**3**3 }}`` is evaluated as ``(3**3)**3`` in Jinja, but would
be evaluated as ``3**(3**3)`` in Python. Use parentheses in Jinja
to be explicit about what order you want. It is usually preferable
to do extended math in Python and pass the results to ``render``
rather than doing it in the template.

This behavior may be changed in the future to match Python, if it's
possible to introduce an upgrade path.


Comparisons
~~~~~~~~~~~
Expand Down