Changes between Initial Version and Version 2 of Ticket #625
- Timestamp:
- Oct 14, 2005, 9:38:58 AM (19 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #625 – Description
initial v2 1 1 This patch includes two decorators for making template tags easier to create. 2 2 {{{ 3 3 @simple_tag : 4 4 }}} 5 5 This one is for converting functions that return a string into template tags. eg. 6 6 7 7 definition: 8 8 {{{ 9 9 @simple_tag 10 10 def monkey_tag(verb): 11 11 return "I %s no evil" % verb 12 12 }}} 13 13 use: 14 14 {{{ 15 15 {% monkey_tag "hear"%} 16 16 }}} 17 17 arguments are resolved using template.resolve_variable -> ie currently limited to variable references and constant strings. 18 18 {{{ 19 19 @inclusion_tag 20 20 }}} 21 21 This 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 : 22 22 path - required path to template … … 27 27 28 28 eg: 29 29 {{{ 30 30 @inclusion_tag('farming/cow_detail') 31 31 def cow_display(cow): … … 34 34 'similar': find_similar_cows(cow) 35 35 } 36 36 }}} 37 37 template : 'farming/cow_detail' 38 {{{ 38 39 <div> 39 40 <h2>{{name}}</h2> … … 43 44 {% end for %} 44 45 </div> 45 46 }}} 46 47 use: 48 {{{ 47 49 {% cow_display cow %} 50 }}}