"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "docs/dev_guide/placeholders.rst" between
cheetah3-3.1.0.tar.gz and cheetah3-3.2.0.tar.gz

About: Cheetah3 is a template engine and code generation tool for e.g. for Web development or Java, SQL, LaTeX, form email ... (written in Python).

placeholders.rst  (cheetah3-3.1.0):placeholders.rst  (cheetah3-3.2.0)
Placeholders Placeholders
============ ============
(placeholders)
Simple placeholders Simple placeholders
------------------- -------------------
(placeholders.simple)
Let's add a few $placeholders to our template: Let's add a few $placeholders to our template:
:: ::
>>> from Cheetah.Template import Template >>> from Cheetah.Template import Template
>>> values = {'what': 'surreal', 'punctuation': '?'} >>> values = {'what': 'surreal', 'punctuation': '?'}
>>> t = Template("""\ >>> t = Template("""\
... Hello, $what world$punctuation ... Hello, $what world$punctuation
... One of Python's least-used functions is $xrange. ... One of Python's least-used functions is $xrange.
... """, [values]) ... """, [values])
skipping to change at line 181 skipping to change at line 177
{VFS}, remember, is a function imported from {Cheetah.NameMapper} {VFS}, remember, is a function imported from {Cheetah.NameMapper}
that looks up a value in a searchList. So we pass it the that looks up a value in a searchList. So we pass it the
searchList, the name to look up, and a boolean (1) indicating we searchList, the name to look up, and a boolean (1) indicating we
want autocalling. (It's {1} rather than {True} because it's want autocalling. (It's {1} rather than {True} because it's
generated from an {and} expression, and that's what Python 2.2 generated from an {and} expression, and that's what Python 2.2
outputs for true {and} expressions.) outputs for true {and} expressions.)
Complex placeholders Complex placeholders
-------------------- --------------------
(placeholders.complex)
Placeholders can get far more complicated than that. This example Placeholders can get far more complicated than that. This example
shows what kind of code the various NameMapper features produce. shows what kind of code the various NameMapper features produce.
The formulas are taken from Cheetah's test suite, in the The formulas are taken from Cheetah's test suite, in the
{Cheetah.Tests.SyntaxAndOutput.Placeholders} class. {Cheetah.Tests.SyntaxAndOutput.Placeholders} class.
:: ::
1 placeholder: $aStr 1 placeholder: $aStr
2 placeholders: $aStr $anInt 2 placeholders: $aStr $anInt
2 placeholders, back-to-back: $aStr$anInt 2 placeholders, back-to-back: $aStr$anInt
 End of changes. 3 change blocks. 
6 lines changed or deleted 0 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)