3 ms·
Actually it's possible too class partial(dict): ... def __getitem__(self, k): ... return open(k).read() So we will render the template like this
by fatih-erikli 5y ago
Actually it's possible too
class partial(dict):
... def __getitem__(self, k):
... return open(k).read()
So we will render the template like this
template.html:
<header><h3>%(header)s</h3></header>
<div>%(content)s</div>
<footer>%(footer.html)s</footer>
generate.py
content = """# This is a markdown content"""
with open('output.html', 'w') as f:
f.write(open('template.html').read() % partial({
title: 'Velkommen',
content: markdown.markdown('markdown content')
}))