Fixed typos in documentation
Before adoption: this commit came in with the history the project adopted, so no landing records it.
--HG-- branch : trunk
authored by Lukas Meuser · committed by Lukas Meuser · parent 187bde1 · Browse files · 6 files·+33 added−29 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
6 files+33 added−29 removed
- other:+33 added−29 removed
Provenance
- Commit
ad48a2e- Tree
c335797- Author
Lukas Meuser <mq@quittenbrod.de>- Committer
Lukas Meuser <mq@quittenbrod.de>- Parent
187bde1
6 files changed+33 added−29 removed
modified:docs/api.rst+3 added-3 removed
70 unmodified lines71 see :ref:`writing-filters`.72 73 .. attribute:: tests74 75- A dict of test funcitons for this environment. As long as no76- template way loaded it's safe to modify this dict. For custom tests75+ A dict of test functions for this environment. As long as no76+ template was loaded it's safe to modify this dict. For custom tests77 see :ref:`writing-tests`.78 79 .. attribute:: globals80 81 A dict of global variables. These variables are always available82 in a template and (if the optimizer is enabled) may not be83- override by templates. As long as no template was loaded it's safe83+ overridden by templates. As long as no template was loaded it's safe84 to modify this dict. For more details see :ref:`global-namespace`.85 86 87 .. autoclass:: jinja2.Template249 unmodified linesmodified:docs/templates.rst+20 added-19 removed
98 unmodified lines99 Beside filters there are also so called "tests" available. Tests can be used100 to test a variable against a common expression. To test a variable or101 expression you add `is` plus the name of the test after the variable. For102 example to find out if a variable is defined you can do ``name is defined``103-which will then return true or false depening on if `name` is defined.103+which will then return true or false depending on if `name` is defined.104 105 Tests can accept arguments too. If the test only takes one argument you can106 leave out the parentheses to group them. For example the following two107 expressions do the same::108 109 {% if loop.index is divisibleby 3 %}110 {% if loop.index is divisibleby(3) %}111 112-The :ref:`builtin-tests` below descibes all the builtin tests.112+The :ref:`builtin-tests` below describes all the builtin tests.113 114 115 Comments116 --------157 unmodified lines274 of tainted values so the information if a value is safe or unsafe can get275 lost. If the information is lost escaping will take place which means that276 you could end up with double escaped contents.277 278-Double escaping is easy to avoid however, just relay on the tools Jinja2278+Double escaping is easy to avoid however, just rely on the tools Jinja2279 provides and don't use builtin Python constructs such as the string modulo280 operator.281 282 Functions returning template data (macros, `super`, `self.BLOCKNAME`) return14 unmodified lines297 298 For299 ~~~300 301-Loop over each item in a sequece. For example, to display a list of users301+Loop over each item in a sequence. For example, to display a list of users302 provided in a variable called `users`::303 304 <h1>Members</h1>305 <ul>26 unmodified lines332 | `loop.cycle` | A helper function to cycle between a list of |333 | | sequences. See the explanation below. |334 +-----------------------+---------------------------------------------------+335 336-Within a for-loop, it's psosible to cycle among a list of strings/variables336+Within a for-loop, it's possible to cycle among a list of strings/variables337 each time through the loop by using the special `loop.cycle` helper::338 339 {% for row in rows %}340 <li class="{{ loop.cycle('odd', 'even') }}">{{ row }}</li>57 unmodified lines398 399 Macros400 ~~~~~~401 402-Macros comparable with functions in regular programming languages. They are403-useful to put often used idoms into reusable functions to not repeat yourself.402+Macros are comparable with functions in regular programming languages. They403+are useful to put often used idioms into reusable functions to not repeat404+yourself.405 405-Macros can be defined in helper templates with then are :ref:`imported <import>`406-or directly in the template where they are used. There is one big difference407-between those two possibilities. A macro that is defined in the template where408-it's also used has access to the context passed to the template. A macro409-defined in another template and then imported can only access variables defined410-there or in the global context.406+Macros can be defined in helper templates which then are :ref:`imported407+<import>` or directly in the template where they are used. There is one big408+difference between those two possibilities. A macro that is defined in the409+template where it's also used has access to the context passed to the template.410+A macro defined in another template and then imported can only access variables411+defined there or in the global context.412 413 Here a small example of a macro that renders a form element::414 415 {% macro input(name, value='', type='text', size=20) -%}5 unmodified lines421 422 <p>{{ input('username') }}</p>423 <p>{{ input('password', type='password') }}</p>424 424-If the macro was defiend in a different template you have to425+If the macro was defined in a different template you have to426 :ref:`import <import>` it first.427 428 Inside macros you have access to three special variables:429 430 `varargs`430- If more positional arguments are passed to the macro then accepted by the431+ If more positional arguments are passed to the macro than accepted by the432 macro they end up in the special `varargs` variable as list of values.433 434 `kwargs`435 Like `varargs` but for keyword arguments. All unconsumed keyword436 arguments are stored in this special variable.437 438 `caller`438- If the macro was called from a :ref:`call` tag the caller is stored in439- this variable as macro which can be called.439+ If the macro was called from a :ref:`call<call>` tag the caller is stored440+ in this variable as macro which can be called.441 442 Macros also expose some of their internal details. The following attributes443 are available on a macro object:444 15 unmodified lines460 accesses the special `varargs` variable).461 462 `caller`463 This is `true` if the macro accesses the special `caller` variable and may463- be called from a :ref:`call` tag.464+ be called from a :ref:`call<call>` tag.465 466 467 .. _call:468 181 unmodified lines650 only has one item you have to end it with a comma. Tuples are usually651 used to represent items of two or more elements. See the example above652 for more details.653 653-{'dict': 'of', 'keys': 'and', 'value': 'pairs'}:654+{'dict': 'of', 'key': 'and', 'value': 'pairs'}:655 A dict in Python is a structure that combines keys and values. Keys must656 be unique and always have exactly one value. Dicts are rarely used in657 templates, they are useful in some rare cases such as the :func:`xmlattr`658 filter.161 unmodified linesmodified:jinja2/environment.py+3 added
89 unmodified lines90 91 `variable_start_string`92 The string marking the begin of a print statement.93 Defaults to ``'{{'``.94+ 95+ `variable_stop_string`96+ The string marking the end of a print statement. Defaults to ``'}}'``.97 98 `comment_start_string`99 The string marking the begin of a comment. Defaults to ``'{#'``.100 560 unmodified linesmodified:jinja2/filters.py+2 added-2 removed
199 unmodified lines200 @environmentfilter201 def do_join(environment, value, d=u''):202 """Return a string which is the concatenation of the strings in the203 sequence. The separator between elements is an empty string per204- default, you can define ith with the optional parameter:204+ default, you can define it with the optional parameter:205 206 .. sourcecode:: jinja207 208 {{ [1, 2, 3]|join('|') }}32 unmodified lines241 242 243 @environmentfilter244 def do_first(environment, seq):245- """Return the frist item of a sequence."""245+ """Return the first item of a sequence."""246 try:247 return iter(seq).next()248 except StopIteration:249 return environment.undefined('No first item, sequence was empty.')424 unmodified linesmodified:jinja2/tests.py+1 added-1 removed
20 unmodified lines21 return value % 2 == 122 23 24 def test_even(value):25- """Return true of the variable is even."""25+ """Return true if the variable is even."""26 return value % 2 == 027 28 29 def test_divisibleby(value, num):107 unmodified linesmodified:jinja2/utils.py+4 added-4 removed
406 unmodified lines407 # markup type which is define above.408 try:409 from jinja2._speedups import escape, soft_unicode410 except ImportError:411- def escape(obj):411+ def escape(s):412 """Convert the characters &, <, >, and " in string s to HTML-safe413 sequences. Use this if you need to display text that might contain414 such characters in HTML.415 """416- if hasattr(obj, '__html__'):417- return obj.__html__()418- return Markup(unicode(obj)416+ if hasattr(s, '__html__'):417+ return s.__html__()418+ return Markup(unicode(s)419 .replace('&', '&')420 .replace('>', '>')421 .replace('<', '<')422 .replace('"', '"')23 unmodified lines