def parse_template(filename, path='views/', context=dict(), lexers={}, delimiters=('{{', '}}')):
 if isinstance(filename, str):
  fname = os.path.join(path, filename)
  try:
   with open(fname, 'rb') as fp:
    text = fp.read()
  except IOError:
   raise RestrictedError(filename, '', 'Unable to find the file')
 else:
  text = filename.read()
 text = to_native(text)
 return str(TemplateParser(text, context=context, path=path, lexers=lexers, delimiters=delimiters))

def parse_template ( filename , path = 'views/' , context = dict ( ) , lexers = { } , delimiters = ( '{{' , '}}' ) ) : if isinstance ( filename , str ) : fname = os . path . join ( path , filename ) try : with open ( fname , 'rb' ) as fp : text = fp . read ( ) except IOError : raise RestrictedError ( filename , '' , 'Unable to find the file' ) else : text = filename . read ( ) text = to_native ( text ) return str ( TemplateParser ( text , context = context , path = path , lexers = lexers , delimiters = delimiters ) )
args: filename: can be a view filename in the views folder or an input stream path: is the path of a views folder context: is a dictionary of symbols used to render the template lexers: dict of custom lexers to use delimiters: opening and closing tags .