some documentation improvements, jinja escapes " and ' now, both into charpoints and no named entities for html 3.2 support ;-)
--HG--
branch : trunk
diff --git a/docs/_static/print.css b/docs/_static/print.css
index 2fea4d6..fb633d8 100644
--- a/docs/_static/print.css
+++ b/docs/_static/print.css
@@ -1,6 +1,5 @@
div.header, div.relnav, #toc { display: none; }
#contentwrapper { padding: 0; margin: 0; border: none; }
body { color: black; background-color: white; }
-div.footer { text-align: right; border-top: 1px solid #888; color: #888;
- margin-top: 1cm; }
+div.footer { border-top: 1px solid #888; color: #888; margin-top: 1cm; }
div.footer a { text-decoration: none; }
diff --git a/docs/_static/style.css b/docs/_static/style.css
index 1068a33..7bddacc 100644
--- a/docs/_static/style.css
+++ b/docs/_static/style.css
@@ -8,10 +8,10 @@
}
div.footer {
- border-top: 1px solid #111;
+ border-top: 1px solid black;
padding: 8px;
font-size: 11px;
- text-align: center;
+ text-align: right;
}
div.footer a {
@@ -26,7 +26,7 @@
div.relnav {
border-bottom: 1px solid #ACACAC;
background: url(navigation.png);
- padding: 2px 20px 0 38px;
+ padding: 2px 20px 0 28px;
line-height: 25px;
color: #aaa;
font-size: 12px;
@@ -56,18 +56,27 @@
}
h1.heading {
- margin: 0 0 0 20px;
+ margin: 0;
padding: 0;
height: 80px;
- background: url(jinjabanner.png) no-repeat;
+}
+
+h1.heading:hover {
+ background: #222;
}
h1.heading a {
+ background: url(jinjabanner.png) no-repeat 20px 0;
display: block;
- width: 200px;
+ width: 100%;
height: 80px;
}
+h1.heading a:focus {
+ -moz-outline: none;
+ outline: none;
+}
+
h1.heading span {
display: none;
}
diff --git a/docs/_static/watermark.png b/docs/_static/watermark.png
index a5a56e1..cc5eb33 100644
--- a/docs/_static/watermark.png
+++ b/docs/_static/watermark.png
Binary files differ
diff --git a/docs/_templates/layout.html b/docs/_templates/layout.html
index b0e3488..0e80308 100644
--- a/docs/_templates/layout.html
+++ b/docs/_templates/layout.html
@@ -45,7 +45,8 @@
<body>
<div id="content">
<div class="header">
- <h1 class="heading"><a href="{{ pathto('index') }}"><span>Jinja</span></a></h1>
+ <h1 class="heading"><a href="{{ pathto('index') }}"
+ title="back to the documentation overview"><span>Jinja</span></a></h1>
</div>
<div class="relnav">
{%- if prev %}
diff --git a/docs/api.rst b/docs/api.rst
index fa601dd..0b33a43 100644
--- a/docs/api.rst
+++ b/docs/api.rst
@@ -124,7 +124,7 @@
-----------
.. autoclass:: jinja2.runtime.Context
- :members: super, get, get_exported, get_all
+ :members: resolve, get_exported, get_all
.. attribute:: parent
diff --git a/docs/templates.rst b/docs/templates.rst
index 8d58213..615884a 100644
--- a/docs/templates.rst
+++ b/docs/templates.rst
@@ -126,6 +126,95 @@
{% endfor %}
#}
+
+Whitespace Control
+------------------
+
+In the default configuration whitespace is not further modified by the
+template engine, so each whitespace (spaces, tabs, newlines etc.) is returned
+unchanged. If the application configures Jinja to `trim_blocks` the first
+newline after a a template tag is removed automatically (like in PHP).
+
+But you can also strip whitespace in templates by hand. If you put an minus
+sign (``-``) to the start or end of an block (for example a for tag), a
+comment or variable expression you can remove the whitespaces after or before
+that block::
+
+ {% for item in seq -%}
+ {{ item }}
+ {%- endfor %}
+
+This will yield all elements without whitespace between them. If `seq` was
+a list of numbers from ``1`` to ``9`` the output would be ``123456789``.
+
+Note that you must not use a whitespace between the tag and the minus sign:
+
+ valid:
+ {%- if foo -%}...{% endif %}
+
+ invalid:
+
+ {% - if foo - %}...{% endif %}
+
+If :ref:`line-statements` are enabled they strip leading whitespace
+automatically up to the beginning of the line.
+
+
+Escaping
+--------
+
+It is sometimes desirable or even necessary to have Jinja ignore parts it
+would otherwise handle as variables or blocks. For example if the default
+syntax is used and you want to use ``{{`` as raw string in the template and
+not start a variable you have to use a trick.
+
+The easiest way is to output the variable delimiter (``{{``) by using a
+variable expression::
+
+ {{ '{{' }}
+
+For bigger sections it makes sense to mark a block `raw`. For example to
+put Jinja syntax as example into a template you can use this snippet::
+
+ {% raw %}
+ <ul>
+ {% for item in seq %}
+ <li>{{ item }}</li>
+ {% endfor %}
+ </ul>
+ {% endraw %}
+
+
+.. _line-statements:
+
+Line Statements
+---------------
+
+If line statements are enabled by the application it's possible to mark a
+line as a statement. For example if the line statement prefix is configured
+to ``#`` the following two examples are equivalent::
+
+ <ul>
+ # for item in seq
+ <li>{{ item }}</li>
+ # endfor
+ </ul>
+
+ <ul>
+ {% for item in seq %}
+ <li>{{ item }}</li>
+ {% endfor %}
+ </ul>
+
+The line statement prefix can appear anywhere on the line as long as no text
+precedes it. For better readability statements that start a block (such as
+`for`, `if`, `elif` etc.) may end with a colon::
+
+ # for item in seq:
+ ...
+ # endif
+
+
.. _template-inheritance:
Template Inheritance