From: Armin Ronacher Date: Mon, 15 Mar 2010 02:06:04 +0000 (+0100) Subject: More documentation updates. X-Git-Tag: 2.4~12 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=30fda27053db020ef4af42c9f1834398f12939ba;p=jinja2.git More documentation updates. --HG-- branch : trunk --- diff --git a/docs/api.rst b/docs/api.rst index a1ea62c..22e1d10 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -627,6 +627,18 @@ must only happen with a :class:`nodes.EvalContextModifier` and :class:`nodes.ScopedEvalContextModifier` from an extension, not on the eval context object itself. +.. autoclass:: nodes.EvalContext + + .. attribute:: autoescape + + `True` or `False` depending on if autoescaping is active or not. + + .. attribute:: volatile + + `True` if the compiler cannot evaluate some expressions at compile + time. At runtime this should always be `False`. + + .. _writing-tests: Custom Tests diff --git a/jinja2/nodes.py b/jinja2/nodes.py index afc7355..d6157a4 100644 --- a/jinja2/nodes.py +++ b/jinja2/nodes.py @@ -68,7 +68,9 @@ class NodeType(type): class EvalContext(object): - """Holds evaluation time information""" + """Holds evaluation time information. Custom attributes can be attached + to it in extensions. + """ def __init__(self, environment): self.autoescape = environment.autoescape @@ -836,12 +838,21 @@ class Scope(Stmt): class EvalContextModifier(Stmt): - """Modifies the eval context""" + """Modifies the eval context. For each option that should be modified, + a :class:`Keyword` has to be added to the :attr:`options` list. + + Example to change the `autoescape` setting:: + + EvalContextModifier(options=[Keyword('autoescape', Const(True))]) + """ fields = ('options',) class ScopedEvalContextModifier(EvalContextModifier): - """Modifies the eval context and reverts it later.""" + """Modifies the eval context and reverts it later. Works exactly like + :class:`EvalContextModifier` but will only modify the + :class:`EvalContext` for nodes in the :attr:`body`. + """ fields = ('body',)