3 ms·
I wanted to be able to create new layouts without touching the precompiler. To rely only on HTML/CSS/Markdown to code the frontend. You can't code partials with
by malkosta 5y ago
I wanted to be able to create new layouts without touching the precompiler.
To rely only on HTML/CSS/Markdown to code the frontend.
You can't code partials within the HTML file with your solution.
- fatih-erikli 5y agoActually 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') }))