parameters: (line)
return_statement: return Task.funex(fun)
docstring: Compile a template expression into a python function (like jsps, but way shorter)
docstring_summary: Compile a template expression into a python function (like jsps, but way shorter)
docstring_tokens: Compile a template expression into a python function ( like jsps but way shorter )
function: def compile_template(line):
  	"""
  	Compile a template expression into a python function (like jsps, but way shorter)
  	"""
  	extr = []
  	def repl(match):
  		g = match.group
  		if g('dollar'): return "$"
  		elif g('backslash'):
  			return "\\"
  		elif g('subst'):
  			extr.append(g('code'))
  			return "<<|@|>>"
  		return None
  	
  	line2 = reg_act.sub(repl, line)
  	params = line2.split('<<|@|>>')
  	assert(extr)	
  
  	indent = 0
  	buf = []
  	app = buf.append
  
  	def app(txt):		
  		buf.append(indent * '\t' + txt)
  
  	for x in range(len(extr)):
  		if params[x]:
  			app("lst.append(%r)" % params[x])
  
  		f = extr[x]
  		if f.startswith('if') or f.startswith('for'):
  			app(f + ':')
  			indent += 1
  		elif f.startswith('py:'):
  			app(f[3:])
  		elif f.startswith('endif') or f.startswith('endfor'):
  			indent -= 1
  		elif f.startswith('else') or f.startswith('elif'):
  			indent -= 1
  			app(f + ':')
  			indent += 1
  		elif f.startswith('xml:'):
  			app('lst.append(xml_escape(%s))' % f[4:])
  		else:
  			#app('lst.append((%s) or "cannot find %s")' % (f, f))
  			app('lst.append(%s)' % f)
  
  	if extr:
  		if params[-1]:
  			app("lst.append(%r)" % params[-1])
  		
  	fun = COMPILE_TEMPLATE % "\n\t".join(buf)
  	#print(fun)
  	return Task.funex(fun)
function_tokens: def compile_template ( line ) : extr = [ ] def repl ( match ) : g = match . group if g ( 'dollar' ) : return "$" elif g ( 'backslash' ) : return "\\" elif g ( 'subst' ) : extr . append ( g ( 'code' ) ) return "<<|@|>>" return None line2 = reg_act . sub ( repl , line ) params = line2 . split ( '<<|@|>>' ) assert ( extr ) indent = 0 buf = [ ] app = buf . append def app ( txt ) : buf . append ( indent * '\t' + txt ) for x in range ( len ( extr ) ) : if params [ x ] : app ( "lst.append(%r)" % params [ x ] ) f = extr [ x ] if f . startswith ( 'if' ) or f . startswith ( 'for' ) : app ( f + ':' ) indent += 1 elif f . startswith ( 'py:' ) : app ( f [ 3 : ] ) elif f . startswith ( 'endif' ) or f . startswith ( 'endfor' ) : indent -= 1 elif f . startswith ( 'else' ) or f . startswith ( 'elif' ) : indent -= 1 app ( f + ':' ) indent += 1 elif f . startswith ( 'xml:' ) : app ( 'lst.append(xml_escape(%s))' % f [ 4 : ] ) else : #app('lst.append((%s) or "cannot find %s")' % (f, f)) app ( 'lst.append(%s)' % f ) if extr : if params [ - 1 ] : app ( "lst.append(%r)" % params [ - 1 ] ) fun = COMPILE_TEMPLATE % "\n\t" . join ( buf ) #print(fun) return Task . funex ( fun )