Skip to content
Myr

removed esection about Jinja semantics as we don't have local aliasing currently

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent 522cad6 · Browse files · 1 file+0 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

1 file+0 added−29 removed

  • other:+0 added−29 removed

1 file+0 added−29 removed

modified:docs/api.rst-29 removed
367 unmodified lines
368context. This is the place where you can put variables and functions369that should be available all the time. Additionally :attr:`Template.globals`370exist that are variables available to a specific template that are available371to all :meth:`~Template.render` calls.372373374Jinja2 Semantics375----------------376377Jinja2 behaves like regular Python code in the runtime with some additional378restrictions that allow the template engine to optimize some common idoms.379The context is semi immutable. Only Jinja2 itself may modify it, if other380code (such as :func:`contextfunction`\s) modify it the changes won't show up381as expected.382383Another change to regular Python is that Jinja2 sees attributes as immutable.384It assumes that every time it accesses `foo.bar`, bar will look the same as385long as `foo` was not overriden. In some situations Jinja will take advantage386of that to internally substitute continuous lookups to the same attributes387with a copy of the attribute.388389For example in the following template the `post.user` attribute is looked up390once:391392.. sourcecode:: html+jinja393394 {% if post.user %}395 <h3>{{ post.user.username }}</h3>396 <p>Location: {{ post.user.location }}</p>397 {% endif %}398399That said, the objects passed to the template may not generate different400values every time a property is accessed.