Archive for September, 2011
Recently while working on a full-blown TurboGears based CMS for our main site it got to me the idea of creating a script to generate a simple static site from a series of Jinja2 templates, simple enough, uh? well at first I looked for a few alternatives but rapidly gave up and ended working on something of my own, as I deemed the task as a mundane and simple thing to do, it was faster creating a script than looking for one and see how it works.
Long story short, it wasn’t really that simple, there are many things to consider, such as paths, if you want to preview the output locally, relative paths will not work very well; I added a switch to my script to transform paths and a function to use on the template, suddenly I found myself adding more things like this, such as a variable for the name of the template so a menu template can check which is the current page and act accordingly.
As far as now is not that complex but a pretty handy script you could easily modify on your own, I posted the code on github:
As next move I would like to add a daemon mode or monitor mode so it will rebuild the output when it detects a change on the files, support for managing other files is also needed, opening the browser to preview after build would be nice, etc.