<s> from django . template import Library , Node , Variable , VariableDoesNotExist <EOL> from django . core . urlresolvers import reverse <EOL> from job_board . views import job_list_by_tag <EOL> register = Library ( ) <EOL> def do_populate_tags ( parser , token ) : <EOL> """<STR_LIT>""" <EOL> bits = token . split_contents ( ) <EOL> print bits <EOL> return PopulateTagsNode ( bits [ <NUM_LIT:1> ] ) <EOL> class PopulateTagsNode ( Node ) : <EOL> def __init__ ( self , tag ) : <EOL> self . tag_tag = Variable ( tag ) <EOL> def render ( self , context ) : <EOL> try : <EOL> _tag = self . tag_tag . resolve ( context ) <EOL> _font_size = _tag . font_size + <NUM_LIT:10> <EOL> _font_weight = min ( <NUM_LIT> , ( <NUM_LIT> + ( _tag . font_size * <NUM_LIT:100> ) ) ) <EOL> _url = reverse ( job_list_by_tag , kwargs = { '<STR_LIT>' : _tag . name } ) <EOL> return "<STR_LIT>" % ( _font_size , _font_weight , _url , _tag . name ) <EOL> except VariableDoesNotExist : <EOL> return '<STR_LIT>' <EOL> register . tag ( '<STR_LIT>' , do_populate_tags ) </s>
