From: Lukas Meuser Date: Thu, 1 May 2008 16:19:57 +0000 (+0200) Subject: Fixed typos in documentation X-Git-Tag: 2.0rc1~113 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ad48a2e57c028c2d2225c0a2c7f23e74c6582080;p=jinja2.git Fixed typos in documentation --HG-- branch : trunk --- diff --git a/docs/api.rst b/docs/api.rst index a8a6779..a8d488b 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -72,15 +72,15 @@ High Level API .. attribute:: tests - A dict of test funcitons for this environment. As long as no - template way loaded it's safe to modify this dict. For custom tests + A dict of test functions for this environment. As long as no + template was loaded it's safe to modify this dict. For custom tests see :ref:`writing-tests`. .. attribute:: globals A dict of global variables. These variables are always available in a template and (if the optimizer is enabled) may not be - override by templates. As long as no template was loaded it's safe + overridden by templates. As long as no template was loaded it's safe to modify this dict. For more details see :ref:`global-namespace`. diff --git a/docs/templates.rst b/docs/templates.rst index 7c0ed5c..8e5b023 100644 --- a/docs/templates.rst +++ b/docs/templates.rst @@ -100,7 +100,7 @@ Beside filters there are also so called "tests" available. Tests can be used to test a variable against a common expression. To test a variable or expression you add `is` plus the name of the test after the variable. For example to find out if a variable is defined you can do ``name is defined`` -which will then return true or false depening on if `name` is defined. +which will then return true or false depending on if `name` is defined. Tests can accept arguments too. If the test only takes one argument you can leave out the parentheses to group them. For example the following two @@ -109,7 +109,7 @@ expressions do the same:: {% if loop.index is divisibleby 3 %} {% if loop.index is divisibleby(3) %} -The :ref:`builtin-tests` below descibes all the builtin tests. +The :ref:`builtin-tests` below describes all the builtin tests. Comments @@ -275,7 +275,7 @@ of tainted values so the information if a value is safe or unsafe can get lost. If the information is lost escaping will take place which means that you could end up with double escaped contents. -Double escaping is easy to avoid however, just relay on the tools Jinja2 +Double escaping is easy to avoid however, just rely on the tools Jinja2 provides and don't use builtin Python constructs such as the string modulo operator. @@ -298,7 +298,7 @@ in the default syntax. For ~~~ -Loop over each item in a sequece. For example, to display a list of users +Loop over each item in a sequence. For example, to display a list of users provided in a variable called `users`::

Members

@@ -333,7 +333,7 @@ Inside of a for loop block you can access some special variables: | | sequences. See the explanation below. | +-----------------------+---------------------------------------------------+ -Within a for-loop, it's psosible to cycle among a list of strings/variables +Within a for-loop, it's possible to cycle among a list of strings/variables each time through the loop by using the special `loop.cycle` helper:: {% for row in rows %} @@ -399,15 +399,16 @@ If can also be used as :ref:`inline expression ` and for Macros ~~~~~~ -Macros comparable with functions in regular programming languages. They are -useful to put often used idoms into reusable functions to not repeat yourself. +Macros are comparable with functions in regular programming languages. They +are useful to put often used idioms into reusable functions to not repeat +yourself. -Macros can be defined in helper templates with then are :ref:`imported ` -or directly in the template where they are used. There is one big difference -between those two possibilities. A macro that is defined in the template where -it's also used has access to the context passed to the template. A macro -defined in another template and then imported can only access variables defined -there or in the global context. +Macros can be defined in helper templates which then are :ref:`imported +` or directly in the template where they are used. There is one big +difference between those two possibilities. A macro that is defined in the +template where it's also used has access to the context passed to the template. +A macro defined in another template and then imported can only access variables +defined there or in the global context. Here a small example of a macro that renders a form element:: @@ -421,13 +422,13 @@ The macro can then be called like a function in the namespace::

{{ input('username') }}

{{ input('password', type='password') }}

-If the macro was defiend in a different template you have to +If the macro was defined in a different template you have to :ref:`import ` it first. Inside macros you have access to three special variables: `varargs` - If more positional arguments are passed to the macro then accepted by the + If more positional arguments are passed to the macro than accepted by the macro they end up in the special `varargs` variable as list of values. `kwargs` @@ -435,8 +436,8 @@ Inside macros you have access to three special variables: arguments are stored in this special variable. `caller` - If the macro was called from a :ref:`call` tag the caller is stored in - this variable as macro which can be called. + If the macro was called from a :ref:`call` tag the caller is stored + in this variable as macro which can be called. Macros also expose some of their internal details. The following attributes are available on a macro object: @@ -460,7 +461,7 @@ are available on a macro object: `caller` This is `true` if the macro accesses the special `caller` variable and may - be called from a :ref:`call` tag. + be called from a :ref:`call` tag. .. _call: @@ -650,7 +651,7 @@ for Python objects such as strings and numbers. The following literals exist: used to represent items of two or more elements. See the example above for more details. -{'dict': 'of', 'keys': 'and', 'value': 'pairs'}: +{'dict': 'of', 'key': 'and', 'value': 'pairs'}: A dict in Python is a structure that combines keys and values. Keys must be unique and always have exactly one value. Dicts are rarely used in templates, they are useful in some rare cases such as the :func:`xmlattr` diff --git a/jinja2/environment.py b/jinja2/environment.py index 2c370c6..fd4f89c 100644 --- a/jinja2/environment.py +++ b/jinja2/environment.py @@ -91,6 +91,9 @@ class Environment(object): `variable_start_string` The string marking the begin of a print statement. Defaults to ``'{{'``. + + `variable_stop_string` + The string marking the end of a print statement. Defaults to ``'}}'``. `comment_start_string` The string marking the begin of a comment. Defaults to ``'{#'``. diff --git a/jinja2/filters.py b/jinja2/filters.py index 5832700..850079d 100644 --- a/jinja2/filters.py +++ b/jinja2/filters.py @@ -201,7 +201,7 @@ def do_default(value, default_value=u'', boolean=False): def do_join(environment, value, d=u''): """Return a string which is the concatenation of the strings in the sequence. The separator between elements is an empty string per - default, you can define ith with the optional parameter: + default, you can define it with the optional parameter: .. sourcecode:: jinja @@ -242,7 +242,7 @@ def do_center(value, width=80): @environmentfilter def do_first(environment, seq): - """Return the frist item of a sequence.""" + """Return the first item of a sequence.""" try: return iter(seq).next() except StopIteration: diff --git a/jinja2/tests.py b/jinja2/tests.py index 01246ff..37e6f31 100644 --- a/jinja2/tests.py +++ b/jinja2/tests.py @@ -22,7 +22,7 @@ def test_odd(value): def test_even(value): - """Return true of the variable is even.""" + """Return true if the variable is even.""" return value % 2 == 0 diff --git a/jinja2/utils.py b/jinja2/utils.py index e8f6fd7..89617e0 100644 --- a/jinja2/utils.py +++ b/jinja2/utils.py @@ -408,14 +408,14 @@ class LRUCache(object): try: from jinja2._speedups import escape, soft_unicode except ImportError: - def escape(obj): + def escape(s): """Convert the characters &, <, >, and " in string s to HTML-safe sequences. Use this if you need to display text that might contain such characters in HTML. """ - if hasattr(obj, '__html__'): - return obj.__html__() - return Markup(unicode(obj) + if hasattr(s, '__html__'): + return s.__html__() + return Markup(unicode(s) .replace('&', '&') .replace('>', '>') .replace('<', '<')