209 | | Template tag decorators see #625 . This can make defining some template tags very easy. |
| 209 | === Template Tag decorators === |
| 210 | defining tags in the 'standard' branch requires you to parse the string the user enters, and can be quite daunting for a newbie. |
| 211 | |
| 212 | In the new-admin branch you can now create a tag for use in your templates by simply doing the following: |
| 213 | {{{ |
| 214 | from django.core.template.decorators import simple_tag |
| 215 | ... |
| 216 | ... |
| 217 | def monkey_tag(verb): |
| 218 | return "I %s no evil" % verb |
| 219 | monkey_tag = simple_tag(monkey_tag) |
| 220 | |
| 221 | }}} |
| 222 | |
| 223 | you would then just load the tag library in your page like |
| 224 | {{{ |
| 225 | {% load monkey %} |
| 226 | {% monkey_tag "hear" %} |
| 227 | }}} |
| 228 | |
| 229 | Template tag decorators see #625 goes into more detail. |