Skip to content
Myr

[svn] added missing documentation file

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 90a5cb3 · Browse files · 1 file+38 added−0 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+38 added−0 removed

  • other:+38 added−0 removed

1 file+38 added−0 removed

added:docs/src/devrecipies.txt+38 added
1=======================2Recipies For Developers3=======================45Here some recipies for application developers.678Automagic Template Variables9============================1011Python allows some magic stack manipulation which can be used to12pass variables to templates automatically. It's not a recommended13way to pass variables to templates but it can be useful for some14small generation scripts etc.1516Just subclass the environment and add an `autorender` function like17this:1819.. sourcecode:: python2021 import sys22 from jinja import Environment2324 class AutoEnvironment(Environment):2526 def autorender(self):27 return self.render(sys._getframe(1).f_locals)2829You can use it now like this:3031.. sourcecode:: python3233 foo_tmpl = env.get_template('foo.html')3435 def foo():36 seq = range(10)37 foo = "blub"38 return foo_tmpl.autorender()