Ñò ûãtHc @sÕdZddkZddklZddklZlZlZlZl Z l Z ddk l Z ddk Tddk lZddklZd d d gZd Zd efd „ƒYZd efd„ƒYZeZdS(sßPlain text templating engine. This module implements two template language syntaxes, at least for a certain transitional period. `OldTextTemplate` (aliased to just `TextTemplate`) defines a syntax that was inspired by Cheetah/Velocity. `NewTextTemplate` on the other hand is inspired by the syntax of the Django template language, which has more explicit delimiting of directives, and is more flexible with regards to white space and line breaks. In a future release, `OldTextTemplate` will be phased out in favor of `NewTextTemplate`, as the names imply. Therefore the new syntax is strongly recommended for new projects, and existing projects may want to migrate to the new syntax to remain compatible with future Genshi releases. iÿÿÿÿN(tTEXT(tBadDirectiveErrortTemplatetTemplateSyntaxErrortEXECtINCLUDEtSUB(tSuite(t*(t Directive(t interpolatetNewTextTemplatetOldTextTemplatet TextTemplatesrestructuredtext enc Bs°eZdZdefdefdefdefdefdefde fgZ dZ d Z d Z ddddd edd„Zd„Zd„ZeeedƒZd„ZRS(s¾Implementation of a simple text-based template engine. This class will replace `OldTextTemplate` in a future release. It uses a more explicit delimiting style for directives: instead of the old style which required putting directives on separate lines that were prefixed with a ``#`` sign, directives and commenbtsr are enclosed in delimiter pairs (by default ``{% ... %}`` and ``{# ... #}``, respectively). Variable substitution uses the same interpolation syntax as for markup languages: simple references are prefixed with a dollar sign, more complex expression enclosed in curly braces. >>> tmpl = NewTextTemplate('''Dear $name, ... ... {# This is a comment #} ... We have the following items for you: ... {% for item in items %} ... * ${'Item %d' % item} ... {% end %} ... ''') >>> print tmpl.generate(name='Joe', items=[1, 2, 3]).render() Dear Joe, We have the following items for you: * Item 1 * Item 2 * Item 3 By default, no spaces or line breaks are removed. If a line break should not be included in the output, prefix it with a backslash: >>> tmpl = NewTextTemplate('''Dear $name, ... ... {# This is a comment #}\ ... We have the following items for you: ... {% for item in items %}\ ... * $item ... {% end %}\ ... ''') >>> print tmpl.generate(name='Joe', items=[1, 2, 3]).render() Dear Joe, We have the following items for you: * 1 * 2 * 3 Backslashes are also used to escape the start delimiter of directives and comments: >>> tmpl = NewTextTemplate('''Dear $name, ... ... \{# This is a comment #} ... We have the following items for you: ... {% for item in items %}\ ... * $item ... {% end %}\ ... ''') >>> print tmpl.generate(name='Joe', items=[1, 2, 3]).render() Dear Joe, {# This is a comment #} We have the following items for you: * 1 * 2 * 3 :since: version 0.5 tdeftwhent otherwisetfortiftchoosetwithttexts/((?>> tmpl = OldTextTemplate('''Dear $name, ... ... We have the following items for you: ... #for item in items ... * $item ... #end ... ... All the best, ... Foobar''') >>> print tmpl.generate(name='Joe', items=[1, 2, 3]).render() Dear Joe, We have the following items for you: * 1 * 2 * 3 All the best, Foobar RRRRRRRRsA(?:^[ \t]*(?R@R(RARBR RRRCR$RDtlstriptsplitR4RIRRRtstripRJRKRR1(RRRRLRMRNRORHRQR6RRR:RRSRTRURZRVRWR[R\R]((s:/usr/lib64/python2.6/site-packages/genshi/template/text.pyR^sb         $ )    (R_R`RaRbRcRdReRfRgRhRiRjR&R't MULTILINER(R^(((s:/usr/lib64/python2.6/site-packages/genshi/template/text.pyR ís        (RaR&t genshi.coreRtgenshi.template.baseRRRRRRtgenshi.template.evalRtgenshi.template.directivesR tgenshi.template.interpolationR t__all__t __docformat__R R R (((s:/usr/lib64/python2.6/site-packages/genshi/template/text.pyts . Â`