Skip to content

Instantly share code, notes, and snippets.

@pizzapanther
Created July 19, 2017 15:50
Show Gist options
  • Select an option

  • Save pizzapanther/edcecdd4ff69ff75c95b038f0648d962 to your computer and use it in GitHub Desktop.

Select an option

Save pizzapanther/edcecdd4ff69ff75c95b038f0648d962 to your computer and use it in GitHub Desktop.
finds all my templates and bundles them up
def tpl_files ():
tpls = []
base_dir = os.path.join(settings.BASE_DIR, 'static', 'nac')
for root, dirs, files in os.walk(base_dir):
for file in files:
if file.endswith('.html'):
fullpath = os.path.join(root, file)
relpath = fullpath.replace(base_dir + '/', '').replace('/', '-')
relpath = relpath[:-5]
with open(fullpath, 'r') as fh:
tpls.append({'path': relpath, 'content': fh.read()})
return tpls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment