<s> """<STR_LIT>""" <EOL> from django . template . base import Node <EOL> from inspect import getargspec <EOL> from functools import partial <EOL> from . parse_bits import parse_bits <EOL> def simple_block_tag ( register , takes_context = None , name = None ) : <EOL> def dec ( func ) : <EOL> params , varargs , varkw , defaults = getargspec ( func ) <EOL> class SimpleNode ( Node ) : <EOL> def __init__ ( self , nodelist , takes_context , args , kwargs ) : <EOL> self . nodelist = nodelist <EOL> self . takes_context = takes_context <EOL> self . args = args <EOL> self . kwargs = kwargs <EOL> def get_resolved_arguments ( self , context ) : <EOL> resolved_args = [ var . resolve ( context ) for var in self . args ] <EOL> resolved_args = [ self . nodelist . render ( context ) ] + resolved_args <EOL> if self . takes_context : <EOL> resolved_args = [ context ] + resolved_args <EOL> resolved_kwargs = dict ( ( k , v . resolve ( context ) ) <EOL> for k , v in self . kwargs . items ( ) ) <EOL> return resolved_args , resolved_kwargs <EOL> def render ( self , context ) : <EOL> resolved_args , resolved_kwargs = self . get_resolved_arguments ( context ) <EOL> return func ( * resolved_args , ** resolved_kwargs ) <EOL> def tag_compiler ( parser , token , params , varargs , varkw , defaults , <EOL> name , takes_context , function_name ) : <EOL> bits = token . split_contents ( ) [ <NUM_LIT:1> : ] <EOL> bits = [ '<STR_LIT>' ] + bits <EOL> args , kwargs = parse_bits ( parser , bits , params , varargs , varkw , <EOL> defaults , takes_context , name ) <EOL> args = args [ <NUM_LIT:1> : ] <EOL> nodelist = parser . parse ( ( '<STR_LIT>' . format ( function_name ) , ) ) <EOL> parser . delete_first_token ( ) <EOL> return SimpleNode ( nodelist , takes_context , args , kwargs ) <EOL> function_name = ( name or <EOL> getattr ( func , '<STR_LIT>' , func ) . __name__ ) <EOL> compile_func = partial ( tag_compiler , <EOL> params = params , varargs = varargs , varkw = varkw , <EOL> defaults = defaults , name = function_name , <EOL> takes_context = takes_context , function_name = function_name ) <EOL> compile_func . __doc__ = func . __doc__ <EOL> register . tag ( function_name , compile_func ) <EOL> return func <EOL> return dec </s>
