Last active
July 31, 2022 23:52
-
-
Save bryanchow/fb34d7c52d68692b23a26698e5a4ea41 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://gist.github.com/bryanchow/fb34d7c52d68692b23a26698e5a4ea41 | |
from django.template.engine import Engine | |
from django.template.loaders.filesystem import Loader | |
def get_template_source(template_name, dirs=[]): | |
""" | |
Return the raw source code of an unrendered Django template. | |
""" | |
loader = Loader(Engine(), dirs=dirs) | |
template = loader.get_template(template_name) | |
return template.source |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment