I needed a simple static site generator, as one does. I only wanted to re-use the same template across multiple html files. Instead I created something accursed indeed.
I wrote a small program in C that generates C programs in PHP-like way. For example, for this input:
[#
#include <stdio.h>
int main(void) {
for (int i = 0; i < 5; ++i) {
#]
Iteration number <b>[# printf("%d", i); #]</b>
[#
}
}
#]
It generates output like this:
#include <stdio.h>
int main(void) {
for (int i = 0; i < 5; ++i) {
printf("%s", "Iteration number <b>");
printf("%d", i);
printf("%s", "</b>\n");
}
}
It's a very simple templating engine you see. Then I compile the resulting code and here's my page. I also made a makefile. Surely this was easier than learning eleventy, right?..
Oh and yeah, you can include other pages via the C preprocessor's #include mechanism.
Here's the source code for this page. Horrible, right?