Skip to content

Instantly share code, notes, and snippets.

@agamdua
Created May 1, 2014 13:39
Show Gist options
  • Save agamdua/178c6fb5c01d3105b0c9 to your computer and use it in GitHub Desktop.
Save agamdua/178c6fb5c01d3105b0c9 to your computer and use it in GitHub Desktop.
From django.templates.base
def compile_string(template_string, origin):
"Compiles template_string into NodeList ready for rendering"
if settings.TEMPLATE_DEBUG:
from django.template.debug import DebugLexer, DebugParser
lexer_class, parser_class = DebugLexer, DebugParser
else:
lexer_class, parser_class = Lexer, Parser
lexer = lexer_class(template_string, origin)
parser = parser_class(lexer.tokenize())
return parser.parse()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment