<s> from django import template <EOL> from basic . inlines . parser import inlines <EOL> from basic . inlines . models import InlineType <EOL> import re <EOL> register = template . Library ( ) <EOL> @ register . filter <EOL> def render_inlines ( value ) : <EOL> """<STR_LIT>""" <EOL> return inlines ( value ) <EOL> @ register . filter <EOL> def extract_inlines ( value ) : <EOL> return inlines ( value , True ) <EOL> class InlineTypes ( template . Node ) : <EOL> def __init__ ( self , var_name ) : <EOL> self . var_name = var_name <EOL> def render ( self , context ) : <EOL> types = InlineType . objects . all ( ) <EOL> context [ self . var_name ] = types <EOL> return '<STR_LIT>' <EOL> @ register . tag ( name = '<STR_LIT>' ) <EOL> def do_get_inline_types ( parser , token ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> tag_name , arg = token . contents . split ( None , <NUM_LIT:1> ) <EOL> except ValueError : <EOL> raise template . TemplateSyntaxError , "<STR_LIT>" % token . contents . split ( ) [ <NUM_LIT:0> ] <EOL> m = re . search ( r'<STR_LIT>' , arg ) <EOL> if not m : <EOL> raise template . TemplateSyntaxError , "<STR_LIT>" % tag_name <EOL> var_name = m . groups ( ) [ <NUM_LIT:0> ] <EOL> return InlineTypes ( var_name ) </s>
