Skip to content

Instantly share code, notes, and snippets.

@oguna
Created May 18, 2015 16:06
Show Gist options
  • Select an option

  • Save oguna/7efb489c12e47118710f to your computer and use it in GitHub Desktop.

Select an option

Save oguna/7efb489c12e47118710f to your computer and use it in GitHub Desktop.
Python標準のTemplateを使う
# encoding: UTF-8
from string import Template
import os
with open('src/layout.html') as template_file:
s = Template(template_file.read())
for content_file in os.listdir('src/content'):
with open('src/content/'+content_file) as input_file:
c = input_file.read()
with open('out/'+content_file,'w') as output_file:
output_file.write(s.substitute(content=c))
print('exit')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment