Created
May 18, 2015 16:06
-
-
Save oguna/7efb489c12e47118710f to your computer and use it in GitHub Desktop.
Python標準のTemplateを使う
This file contains hidden or 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
| # 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