From 0aa0f58aaeeaf4dc8c4db1dd44016afdddd95087 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Wed, 18 Mar 2009 01:01:36 +0100 Subject: [PATCH] Applied documentation patches by Clemens Hermann. --HG-- branch : trunk --- docs/api.rst | 8 ++++---- docs/intro.rst | 2 +- docs/templates.rst | 23 +++++++++++------------ jinja2/environment.py | 4 ++-- jinja2/filters.py | 8 ++++---- 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index a12b6a1..5383293 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -14,7 +14,7 @@ Basics Jinja2 uses a central object called the template :class:`Environment`. Instances of this class are used to store the configuration, global objects and are used to load templates from the file system or other locations. -Even if you are creating templates from string by using the constructor of +Even if you are creating templates from strings by using the constructor of :class:`Template` class, an environment is created automatically for you, albeit a shared one. @@ -61,7 +61,7 @@ Python 2.x supports two ways of representing string objects. One is the `str` type and the other is the `unicode` type, both of which extend a type called `basestring`. Unfortunately the default is `str` which should not be used to store text based information unless only ASCII characters are -used. With Python 2.6 it is possible to my `unicode` the default on a per +used. With Python 2.6 it is possible to make `unicode` the default on a per module level and with Python 3 it will be the default. To explicitly use a unicode string you have to prefix the string literal @@ -161,7 +161,7 @@ useful if you want to dig deeper into Jinja2 or :ref:`develop extensions some operations. All parameters except of `hint` should be provided as keyword parameters for better readability. The `hint` is used as error message for the exception if provided, otherwise the error - message generated from `obj` and `name` automatically. The exception + message will be generated from `obj` and `name` automatically. The exception provided as `exc` is raised if something with the generated undefined object is done that the undefined object does not allow. The default exception is :exc:`UndefinedError`. If a `hint` is provided the @@ -540,7 +540,7 @@ Inside the template it can then be used as follows: publication date: {{ article.pub_date|datetimeformat('%d-%m-%Y') }} Filters can also be passed the current template context or environment. This -is useful if a filters wants to return an undefined value or check the current +is useful if a filter wants to return an undefined value or check the current :attr:`~Environment.autoescape` setting. For this purpose two decorators exist: :func:`environmentfilter` and :func:`contextfilter`. diff --git a/docs/intro.rst b/docs/intro.rst index 49c745b..e290655 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -101,7 +101,7 @@ Or the new `pip`_ command:: sudo pip install Jinja2==dev -.. _download page: http://jinja.pocoo.org/2/download +.. _download page: http://pypi.python.org/pypi/Jinja2 .. _setuptools: http://peak.telecommunity.com/DevCenter/setuptools .. _easy_install: http://peak.telecommunity.com/DevCenter/EasyInstall .. _pip: http://pypi.python.org/pypi/pip diff --git a/docs/templates.rst b/docs/templates.rst index 9fd9692..2187638 100644 --- a/docs/templates.rst +++ b/docs/templates.rst @@ -109,7 +109,7 @@ applied to the next. ``{{ name|striptags|title }}`` for example will remove all HTML Tags from the `name` and title-cases it. Filters that accept arguments have parentheses around the arguments, like a function call. This example will join a list -by spaces: ``{{ list|join(', ') }}``. +by commas: ``{{ list|join(', ') }}``. The :ref:`builtin-filters` below describes all the builtin filters. @@ -836,7 +836,7 @@ Here two examples:: .. admonition:: Note In Jinja 2.0 the context that was passed to the included template - did not include variables define in the template. As a matter of + did not include variables defined in the template. As a matter of fact this did not work:: {% for box in boxes %} @@ -914,16 +914,16 @@ Math ~~~~ Jinja allows you to calculate with values. This is rarely useful in templates -but exists for completeness sake. The following operators are supported: +but exists for completeness' sake. The following operators are supported: \+ - Adds two objects with each other. Usually numbers but if both objects are + Adds two objects together. Usually the objects are numbers but if both are strings or lists you can concatenate them this way. This however is not the preferred way to concatenate strings! For string concatenation have a look at the ``~`` operator. ``{{ 1 + 1 }}`` is ``2``. \- - Substract two numbers from each other. ``{{ 3 - 2 }}`` is ``1``. + Substract the second number from the first one. ``{{ 3 - 2 }}`` is ``1``. / Divide two numbers. The return value will be a floating point number. @@ -934,12 +934,11 @@ but exists for completeness sake. The following operators are supported: ``{{ 20 / 7 }}`` is ``2``. % - Calculate the remainder of an integer division between the left and right - operand. ``{{ 11 % 7 }}`` is ``4``. + Calculate the remainder of an integer division. ``{{ 11 % 7 }}`` is ``4``. \* Multiply the left operand with the right one. ``{{ 2 * 2 }}`` would - return ``4``. This can also be used to repeat string multiple times. + return ``4``. This can also be used to repeat a string multiple times. ``{{ '=' * 80 }}`` would print a bar of 80 equal signs. \** @@ -949,8 +948,8 @@ but exists for completeness sake. The following operators are supported: Logic ~~~~~ -For `if` statements / `for` filtering or `if` expressions it can be useful to -combine group multiple expressions: +For `if` statements, `for` filtering or `if` expressions it can be useful to +combine multiple expressions: and Return true if the left and the right operand is true. @@ -996,7 +995,7 @@ is () Call a callable: ``{{ post.render() }}``. Inside of the parentheses you - can use arguments and keyword arguments like in python: + can use positional arguments and keyword arguments like in python: ``{{ post.render(user, full=true) }}``. . / [] @@ -1085,7 +1084,7 @@ The following functions are available in the global scope by default: loops or over multiple loops. This is for example very useful if you want to show a list of folders and - files, with the folders on top, but both in the same list with alteranting + files, with the folders on top, but both in the same list with alternating row colors. The following example shows how `cycler` can be used:: diff --git a/jinja2/environment.py b/jinja2/environment.py index c7f311e..bfbb662 100644 --- a/jinja2/environment.py +++ b/jinja2/environment.py @@ -656,8 +656,8 @@ class Template(object): def make_module(self, vars=None, shared=False, locals=None): """This method works like the :attr:`module` attribute when called - without arguments but it will evaluate the template every call - rather then caching the template. It's also possible to provide + without arguments but it will evaluate the template on every call + rather than caching it. It's also possible to provide a dict which is then used as context. The arguments are the same as for the :meth:`new_context` method. """ diff --git a/jinja2/filters.py b/jinja2/filters.py index 553ce6e..76cdcc1 100644 --- a/jinja2/filters.py +++ b/jinja2/filters.py @@ -285,8 +285,8 @@ def do_random(environment, seq): def do_filesizeformat(value, binary=False): """Format the value like a 'human-readable' file size (i.e. 13 KB, 4.1 MB, 102 bytes, etc). Per default decimal prefixes are used (mega, - giga etc.), if the second parameter is set to `True` the binary - prefixes are (mebi, gibi). + giga, etc.), if the second parameter is set to `True` the binary + prefixes are used (mebi, gibi). """ bytes = float(value) base = binary and 1024 or 1000 @@ -452,7 +452,7 @@ def do_striptags(value): def do_slice(value, slices, fill_with=None): """Slice an iterator and return a list of lists containing those items. Useful if you want to create a div containing - three div tags that represent columns: + three ul tags that represent columns: .. sourcecode:: html+jinja @@ -498,7 +498,7 @@ def do_batch(value, linecount, fill_with=None): {%- for row in items|batch(3, ' ') %} {%- for column in row %} - {{ column }} + {{ column }} {%- endfor %} {%- endfor %} -- 2.26.2