#NEWLINE# def smart_if( parser , token ) : #NEWLINE# #INDENT# '\n    A smarter {% if %} tag for django templates.\n\n    While retaining current Django functionality, it also handles equality,\n    greater than and less than operators. Some common case examples::\n\n        {% if articles|length >= 5 %}...{% endif %}\n        {% if "ifnotequal tag" != "beautiful" %}...{% endif %}\n\n    Arguments and operators _must_ have a space between them, so\n    ``{% if 1>2 %}`` is not a valid smart if tag.\n\n    All supported operators are: ``or``, ``and``, ``in``, ``=`` (or ``==``),\n    ``!=``, ``>``, ``>=``, ``<`` and ``<=``.\n    ' #NEWLINE# bits = token . split_contents ( ) [ 1 : ] #NEWLINE# var = TemplateIfParser ( parser , bits ) . parse ( ) #NEWLINE# nodelist_true = parser . parse ( ( 'else' , 'endif' ) ) #NEWLINE# token = parser . next_token ( ) #NEWLINE# if ( token . contents == 'else' ) : #NEWLINE# #INDENT# nodelist_false = parser . parse ( ( 'endif' , ) ) #NEWLINE# parser . delete_first_token ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# nodelist_false = None #NEWLINE# #UNINDENT# return SmartIfNode ( var , nodelist_true , nodelist_false )