Created
September 25, 2009 14:16
-
-
Save justquick/193563 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
designed as a functional replacement to james benne | |
eliminates need for app.templatetags | |
all arguments/kwargs are resolved by default | |
comparisons | |
if some comparison, do somethin, otherwise do s | |
add negate at the end of the tag to do the oppo | |
{% if_<comparison> ... %} | |
... | |
{% else %} | |
... | |
{% endif_<comparison> %} | |
functions can have arguments and keyword arguments | |
similar as varname syntax places output into varnam | |
is_inclusion - inclusion tag, function must return | |
{% <function> ... %} | |
what it does | |
load default tags used everywhere automagically | |
uses settings var | |
no need for {% load %} | |
easy conversion of old template tags (but they will | |
from template_utils import functions, compariso | |
hello = lambda: 'hello world' | |
functions.register(hello) | |
register tags anywhere in the standard loaded pytho | |
settings.py | |
views.py, models.py, __init__.py, etc. | |
app.templatetags.function (old school) | |
app.template | |
no import/registration needed, just set fun | |
tags can have handy attrs | |
name - name of tag to use in template | |
takes_context - if true, passes context as firs | |
do_not_resolve - resolves none of the arguments |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment