Fixed example of a division with a truncated integer result (it's // instead of /)
[jinja2.git] / docs / templates.rst
index 26234e01d88943135327f41d6dd4c356c7e115ea..a4a7d30324b313c6e47dd04e08ba3db3e5854448 100644 (file)
@@ -883,8 +883,9 @@ Here two examples::
             {% include "render_box.html" %}
         {% endfor %}
 
-    The included template ``render_box.html`` is not able to access
-    `box` in Jinja 2.0, but in Jinja 2.1.
+    The included template ``render_box.html`` is *not* able to access
+    `box` in Jinja 2.0. As of Jinja 2.1 ``render_box.html`` *is* able
+    to do so.
 
 
 .. _expressions:
@@ -971,7 +972,7 @@ but exists for completeness' sake.  The following operators are supported:
 
 //
     Divide two numbers and return the truncated integer result.
-    ``{{ 20 / 7 }}`` is ``2``.
+    ``{{ 20 // 7 }}`` is ``2``.
 
 %
     Calculate the remainder of an integer division.  ``{{ 11 % 7 }}`` is ``4``.
@@ -985,6 +986,27 @@ but exists for completeness' sake.  The following operators are supported:
     Raise the left operand to the power of the right operand.  ``{{ 2**3 }}``
     would return ``8``.
 
+Comparisons
+~~~~~~~~~~~
+
+==
+    Compares two objects for equality.
+
+!=
+    Compares two objects for inequality.
+
+>
+    `true` if the left hand side is greater than the right hand side.
+
+>=
+    `true` if the left hand side is greater or equal to the right hand side.
+
+<
+    `true` if the left hand side is lower than the right hand side.
+
+<=
+    `true` if the left hand side is lower or equal to the right hand side.
+
 Logic
 ~~~~~
 
@@ -1239,12 +1261,24 @@ For example you can print a translated string easily this way::
 To use placeholders you can use the `format` filter::
 
     {{ _('Hello %(user)s!')|format(user=user.username) }}
-        or
-    {{ _('Hello %s')|format(user.username) }}
 
 For multiple placeholders always use keyword arguments to `format` as other
 languages may not use the words in the same order.
 
+.. versionchanged:: 2.5
+
+If newstyle gettext calls are activated (:ref:`newstyle-gettext`), using
+placeholders is a lot easier:
+
+.. sourcecode:: html+jinja
+
+    {{ gettext('Hello World!') }}
+    {{ gettext('Hello %(name)s!', name='World') }}
+    {{ ngettext('%(num)d apple', '%(num)d apples', apples|count) }}
+
+Note that the `ngettext` function's format string automatically recieves
+the count as `num` parameter additionally to the regular parameters.
+
 
 Expression Statement
 ~~~~~~~~~~~~~~~~~~~~