Changeset 3451:24f2f59e86b6 in livinglogic.python.xist

Show
Ignore:
Timestamp:
07/04/08 15:34:50 (11 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Update documentation for the render tag.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • docs/UL4.rst

    r3450 r3451  
    222222For example we can output the person list only if there are any persons:: 
    223223 
    224     <?if data.persons?> 
     224    <?if persons?> 
    225225    <ul> 
    226     <?for person in data.persons?> 
     226    <?for person in persons?> 
    227227    <li><?print person.lastname?>, <?person.firstname?></li> 
    228228    <?end for?> 
     
    232232``elif`` and ``else`` are supported too:: 
    233233 
    234     <?if data.persons?> 
     234    <?if persons?> 
    235235    <ul> 
    236     <?for person in data.persons?> 
     236    <?for person in persons?> 
    237237    <li><?print person.lastname?>, <?person.firstname?></li> 
    238238    <?end for?> 
     
    244244or:: 
    245245 
    246     <?if len(data.persons)==0?> 
     246    <?if len(persons)==0?> 
    247247    No persons found! 
    248     <?elif len(data.persons)==1?> 
     248    <?elif len(persons)==1?> 
    249249    One person found! 
    250250    <?else?> 
    251     <?print len(data.persons)?> persons found! 
     251    <?print len(persons)?> persons found! 
    252252    <?end if?> 
    253253 
     
    288288    <?if data?>\ 
    289289    <ul> 
    290     <?for item in data?><?render itemtmpl(item)?><?end for?>\ 
     290    <?for item in data?><?render itemtmpl(item=item)?><?end for?>\ 
    291291    </ul> 
    292292    <?end if?>\ 
     
    296296 
    297297    # Template 2 
    298     source2 = u"<li><?print xmlescape(data)?></li>\n" 
     298    source2 = u"<li><?print xmlescape(item)?></li>\n" 
    299299 
    300300    tmpl2 = ul4c.compile(source2) 
     
    306306    templates = dict(itemtmpl=tmpl2) 
    307307 
    308     print tmpl1.renders(data, templates) 
     308    print tmpl1.renders(templates, data=data) 
    309309 
    310310This will output:: 
     
    316316    </ul> 
    317317 
    318 I.e. a dictionary of templates can be passed to the :meth:`renders` method as 
    319 a additional argument. The keys in this dictionary are the names of the 
    320 templates, which can be used in the ``<?render?>`` tag. 
    321 ``<?render itemtmpl(item)?>`` renders the ``itemtmpl`` template and passed the 
    322 ``item`` variable as the data object. All templates available in the outer 
    323 template will be available in the inner template too. 
     318I.e. a dictionary of templates can be passed to the render methods as the first 
     319argument. The keys in this dictionary are the names of the templates, which can 
     320be used in the ``<?render?>`` tag. ``<?render itemtmpl(item)?>`` renders the 
     321``itemtmpl`` template and passed the ``item`` variable, which will be available 
     322in the inner template under the name ``item``. All templates available in the 
     323outer template will be available in the inner template too. 
    324324 
    325325