<s> from django import template <EOL> from settings . local import MEDIA_URL as STATIC_URL <EOL> register = template . Library ( ) <EOL> class StaticLinkNode ( template . Node ) : <EOL> def __init__ ( self , file_type , file_path ) : <EOL> self . file_type = file_type <EOL> if not file_path . endswith ( file_type ) and file_type != "<STR_LIT>" : <EOL> file_path = "<STR_LIT>" % ( file_path , file_type ) <EOL> self . file_path = file_path <EOL> def render ( self , context ) : <EOL> if self . file_type == '<STR_LIT>' : <EOL> tag = "<STR_LIT>" <EOL> tag %= ( STATIC_URL , self . file_path ) <EOL> if self . file_type == '<STR_LIT>' : <EOL> tag = "<STR_LIT>" <EOL> tag %= ( STATIC_URL , self . file_path ) <EOL> if self . file_type == '<STR_LIT>' : <EOL> tag = "<STR_LIT>" <EOL> tag %= ( STATIC_URL , self . file_path ) <EOL> return tag <EOL> def staticlink_tag ( parser , token ) : <EOL> ( staticlink_type , staticlink_file ) = tuple ( token . split_contents ( ) [ <NUM_LIT:1> ] . split ( "<STR_LIT::>" ) ) <EOL> return StaticLinkNode ( staticlink_type , staticlink_file ) <EOL> register . tag ( '<STR_LIT>' , staticlink_tag ) </s>
