<s> """<STR_LIT>""" <EOL> try : <EOL> from django . template import base as template_base <EOL> except ImportError : <EOL> from django import template as template_base <EOL> register = template_base . Library ( ) <EOL> def raw ( parser , token ) : <EOL> text = [ ] <EOL> parse_until = '<STR_LIT>' <EOL> tag_mapping = { <EOL> template_base . TOKEN_TEXT : ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> template_base . TOKEN_VAR : ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> template_base . TOKEN_BLOCK : ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> template_base . TOKEN_COMMENT : ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> } <EOL> while parser . tokens : <EOL> token = parser . next_token ( ) <EOL> if token . token_type == template_base . TOKEN_BLOCK and token . contents == parse_until : <EOL> return template_base . TextNode ( u'<STR_LIT>' . join ( text ) ) <EOL> start , end = tag_mapping [ token . token_type ] <EOL> text . append ( u'<STR_LIT>' % ( start , token . contents , end ) ) <EOL> parser . unclosed_block_tag ( parse_until ) <EOL> raw = register . tag ( raw ) <EOL> def render_field ( field , value = None ) : <EOL> return field . render ( value ) <EOL> render_field = register . filter ( render_field ) <EOL> def sort_by_key ( field , currently ) : <EOL> is_negative = currently . find ( '<STR_LIT:->' ) is <NUM_LIT:0> <EOL> current_field = currently . lstrip ( '<STR_LIT:->' ) <EOL> if current_field == field and is_negative : <EOL> return field <EOL> elif current_field == field : <EOL> return '<STR_LIT:->' + field <EOL> else : <EOL> return field <EOL> sort_by_key = register . filter ( sort_by_key ) <EOL> def sort_field ( sort_string ) : <EOL> return sort_string . lstrip ( '<STR_LIT:->' ) <EOL> sort_field = register . filter ( sort_field ) </s>
