def template_source(request):
 template_origin_name = request.GET.get(u'template_origin', None)
 if (template_origin_name is None):
  return HttpResponseBadRequest(u'"template_origin" key is required')
 template_name = request.GET.get(u'template', template_origin_name)
 final_loaders = []
 loaders = Engine.get_default().template_loaders
 for loader in loaders:
  if (loader is not None):
   if hasattr(loader, u'loaders'):
    final_loaders += loader.loaders
   else:
    final_loaders.append(loader)
 for loader in final_loaders:
  if Origin:
   origin = Origin(template_origin_name)
   try:
    source = loader.get_contents(origin)
    break
   except TemplateDoesNotExist:
    pass
  else:
   try:
    (source, _) = loader.load_template_source(template_name)
    break
   except TemplateDoesNotExist:
    pass
 else:
  source = (u'Template Does Not Exist: %s' % (template_origin_name,))
 try:
  from pygments import highlight
  from pygments.lexers import HtmlDjangoLexer
  from pygments.formatters import HtmlFormatter
  source = highlight(source, HtmlDjangoLexer(), HtmlFormatter())
  source = mark_safe(source)
  source.pygmentized = True
 except ImportError:
  pass
 return render_to_response(u'debug_toolbar/panels/template_source.html', {u'source': source, u'template_name': template_name})

def template_source ( request ) : template_origin_name = request . GET . get ( u'template_origin' , None ) if ( template_origin_name is None ) : return HttpResponseBadRequest ( u'"template_origin" key is required' ) template_name = request . GET . get ( u'template' , template_origin_name ) final_loaders = [ ] loaders = Engine . get_default ( ) . template_loaders for loader in loaders : if ( loader is not None ) : if hasattr ( loader , u'loaders' ) : final_loaders += loader . loaders else : final_loaders . append ( loader ) for loader in final_loaders : if Origin : origin = Origin ( template_origin_name ) try : source = loader . get_contents ( origin ) break except TemplateDoesNotExist : pass else : try : ( source , _ ) = loader . load_template_source ( template_name ) break except TemplateDoesNotExist : pass else : source = ( u'Template Does Not Exist: %s' % ( template_origin_name , ) ) try : from pygments import highlight from pygments . lexers import HtmlDjangoLexer from pygments . formatters import HtmlFormatter source = highlight ( source , HtmlDjangoLexer ( ) , HtmlFormatter ( ) ) source = mark_safe ( source ) source . pygmentized = True except ImportError : pass return render_to_response ( u'debug_toolbar/panels/template_source.html' , { u'source' : source , u'template_name' : template_name } )
return the source of a template .