alex / django-templatetag-sugar

This project exists to make defining template tags in Django kickass
BSD 3-Clause "New" or "Revised" License
211 stars 38 forks source link

Support for boolean tags #3

Open seanbrant opened 14 years ago

seanbrant commented 14 years ago

It would be nice to have an easier way to create boolean tags.

Template:

{% ifequals thing1 thing2 %}
    All Things are created equal
{% else %}
    Things are not equal
{% endifequals %}

Tag:

@boolean_tag(register, [Variable(), Variable()])
def ifequals(context, thing1, thing2):
    return thing1 == thing2

I took a stab at it in my fork. seanbrant/django-templatetag-sugar@ea353e5e50152fe5a353e5aa7fff1fdbb76cf2e0

alex commented 14 years ago

I think this is solving the wrong problem, the issue here is that there's currently no way to handle nodelists at all, I'd prefer not to special case {% if %} type tags.

seanbrant commented 14 years ago

I agree with you. This was just the quickest way to get something that worked for me. I still think support for {% if %} type tags is needed, just not sure the best way to handle it.