#NEWLINE# @ register . tag #NEWLINE# def ifinstalled( parser , token ) : #NEWLINE# #INDENT# '\n    Old-style ``if`` tag that renders contents if the given app is\n    installed. The main use case is:\n\n    {% ifinstalled app_name %}\n    {% include "app_name/template.html" %}\n    {% endifinstalled %}\n\n    so we need to manually pull out all tokens if the app isn\'t\n    installed, since if we used a normal ``if`` tag with a False arg,\n    the include tag will still try and find the template to include.\n    ' #NEWLINE# try : #NEWLINE# #INDENT# ( tag , app ) = token . split_contents ( ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# raise TemplateSyntaxError ( 'ifinstalled should be in the form: {% ifinstalled app_name %}{% endifinstalled %}' ) #NEWLINE# #UNINDENT# end_tag = ( 'end' + tag ) #NEWLINE# unmatched_end_tag = 1 #NEWLINE# if ( app . strip ( '"\'' ) not in settings . INSTALLED_APPS ) : #NEWLINE# #INDENT# while unmatched_end_tag : #NEWLINE# #INDENT# token = parser . tokens . pop ( 0 ) #NEWLINE# if ( token . token_type == TOKEN_BLOCK ) : #NEWLINE# #INDENT# block_name = token . contents . split ( ) [ 0 ] #NEWLINE# if ( block_name == end_tag ) : #NEWLINE# #INDENT# unmatched_end_tag += 1 #NEWLINE# #UNINDENT# if ( block_name == end_tag ) : #NEWLINE# #INDENT# unmatched_end_tag -= 1 #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# parser . tokens . insert ( 0 , token ) #NEWLINE# #UNINDENT# nodelist = parser . parse ( ( end_tag , ) ) #NEWLINE# parser . delete_first_token ( ) #NEWLINE# class IfInstalledNode ( Node ) : #NEWLINE# #INDENT# def render( self , context ) : #NEWLINE# #INDENT# return nodelist . render ( context ) #NEWLINE# #UNINDENT# #UNINDENT# return IfInstalledNode ( )