Not so long ago I decided I want to redo the way my website is generated. For a long time already I've been thinking of making my own HTML templating system, coming up with different ideas, and never implementing them. So, I finally got around to doing it. After 3 days of almost non-stop work exclusively on this one project, I had a working prototype of what I named Durak (after the Russian word дурак meaning fool) — an HTML templating system for static site generation.

I decided implementing a parser from scratch on my own would be too time-consuming, so with some prior experience I chose to use ANTLR, which is a parser generator. The way it works is you write a formal grammar of the language you want to parse, and rules for the lexer (aka tokenizer) that govern what is a token and when. You can use it to generate parsers in many different languages, including Java, Python and C++. I chose Python as I wanted to use the snake for scripting the static site generation in general. I'm quite happy with how the templating language syntax worked out, except for one mancament that I'm not really sure how to resolve. (You need to separate tag attributes with semicolons)

But how does durak help with maintaining a static website? What are its features? Well, there are a few main things that I wanted to achieve with it, and here is a list:

Now, I'll not write an entire guide on how to use it here. (There is documentation and an example available on GitHub) But I will tell you the website you're reading right now is generated using Durak, which is most useful for auto-updating the article list and generating the RSS feed of the blog. (Yes, I finally have an RSS feed) So take that as a taste of its abilities. I can't see why you couldn't also use it for a tagging system on a blog, but I don't need, nor particularly want one for mine.

Links



If you liked the article, consider donating Monero to my address: 45ZFoDAouGHH1gC697mRLPK9zMAxnnnccSYQj1Aa2BJnjZhWnbeojWRE5RKR9CeY7qYtt2eESYC4mYqypxE7sfxqLdLi3Eh (QR)