Задать вопрос

Тел: +7 965 3737 888

556

Просмотров

1

Ответов

Easy Conditional Template Tags

This is a conditional templatetag decorator that makes it very easy to write template tags that can be used as conditions. This can help avoid template boilerplate code (e.g. setting a variable in your template to be used in a condition).

All you have to do is define a function with expected parameters that returns True or False. Examples are in the code.

Вопрос полезен? Да0/Нет0
file_2321.py(3.6Кб)
None

Ответы (1):

Ответhongfaebu:02.04.2013
Ответ полезен? Да0/Нет0

If no defaults arguments are given line 60 fails because it is None and not an empty list.

Changing line 60 to this will fix it.

defaults = argspec[3] and list(argspec[3]) or []

Otherwise an excellent snippet.