<s> from django import template <EOL> from django . conf import settings <EOL> register = template . Library ( ) <EOL> class CheckGrappelli ( template . Node ) : <EOL> def __init__ ( self , var_name ) : <EOL> self . var_name = var_name <EOL> def render ( self , context ) : <EOL> context [ self . var_name ] = '<STR_LIT>' in settings . INSTALLED_APPS <EOL> return '<STR_LIT>' <EOL> def check_grappelli ( parser , token ) : <EOL> """<STR_LIT>""" <EOL> bits = token . contents . split ( ) <EOL> if len ( bits ) != <NUM_LIT:3> : <EOL> raise template . TemplateSyntaxError ( "<STR_LIT>" ) <EOL> if bits [ <NUM_LIT:1> ] != '<STR_LIT>' : <EOL> raise template . TemplateSyntaxError ( "<STR_LIT>" ) <EOL> varname = bits [ <NUM_LIT:2> ] <EOL> return CheckGrappelli ( varname ) <EOL> register . tag ( check_grappelli ) </s>
