templar-gen
templar-gen was coded in a couple of hours to generate static pages just like this one. It is a very simple system that generates static pages utilising the templar templating language from synapticloop.
Page cutting
The generation of pages revolves around determining the common parts of the page, extracting them and including them in multiple files.
The basic commands for including snippets of a page are one of:
{import filename}
when you want to include the file and parse the contents (with templar){static filename}
when you want to include the static contents of the file without parsing the contents{statichtml filename}
when you want to include the static contents of the file and output escaped HTML
usage
Get the latest code from the templar-gen releases directory.
(You will want the templar-gen-<version>-all.jar
jar file)
Command line
run it with the following
java -jar templar-gen.jar <input_directory> <output_directory>
You can of course use Ant or Gradle
Which files are generated
In order for pages to be generated, you need to have both the file and a context file in the directory that is going to be created. If you have a look at the source code for this site - you will see the layout.
For example, in the src directory:
index.html
this is the index.html pageindex.html.context
this is where you can place variables for the index.html page
Having the .context
file means that the file will be generated into the output_directory
This page was generated with the following command line:
java -jar templar-gen.jar src .
Need Help?
There is copious documentation for the templar templating engine over at https://synapticloop.github.io/templar/