Changes between Initial Version and Version 2 of Ticket #625


Ignore:
Timestamp:
Oct 14, 2005, 9:38:58 AM (19 years ago)
Author:
rjwittams
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #625 – Description

    initial v2  
    11This patch includes two decorators for making template tags easier to create.
    2 
     2{{{
    33@simple_tag :
    4 
     4}}}
    55This one is for converting functions that return a string into template tags. eg.
    66
    77definition:
    8 
     8{{{
    99@simple_tag
    1010def monkey_tag(verb):
    1111    return "I %s no evil" % verb
    12 
     12}}}
    1313use:
    14 
     14{{{
    1515{% monkey_tag "hear"%}
    16 
     16}}}
    1717arguments are resolved using template.resolve_variable -> ie currently limited to variable references and constant strings.
    18 
     18{{{
    1919@inclusion_tag
    20 
     20}}}
    2121This decorator turns a function returning a dictionary into a template tag that renders another template inline using that dictionary as the context. The decorator takes three arguments :
    2222path - required path to template
     
    2727
    2828eg:
    29 
     29{{{
    3030@inclusion_tag('farming/cow_detail')
    3131def cow_display(cow):
     
    3434       'similar': find_similar_cows(cow)
    3535    }
    36 
     36}}}
    3737template : 'farming/cow_detail'
     38{{{
    3839<div>
    3940<h2>{{name}}</h2>
     
    4344{% end for %}
    4445</div>
    45 
     46}}}
    4647use:
     48{{{
    4749{% cow_display cow %}
     50}}}
Back to Top