templer is a static-site generator, written in perl, it works on the following assumptions:
- A site is made up of "pages" and "assets".
- A "page" is processed to build HTML output.
- An "asset" is copied from the input-directory to the output-directory with zero changes.
The input pages can be written in Textile, Markdown, or plain HTML - the latter being useful if you've just switched from doing things "by hand".
A lot more documentation is available upon the github repository where development occurs.
Each input page of your templer site consists of a header, a deliminator ( "----"), and the content. This is an example page:title: This is the page title. ---- <p>This is my page body.</p> <p>My title is <-- tmpl_var name='title' -->.</p>
The page declares the variable "title", which may be used in the body or in the layout file - typically a page would have a title to insert in the <title> section of the generated HTML file.
As you can see the title is also displayed in the middle of the page using the standard HTML::Template markup.
The flexible approach to variables is part of the reason why templer exists, because it allows a lot of clever things to be done.
The pages that you write will be wrapped inside a layout prior to being output. The layout is how you define the global appearance for your site.
If you wish you may change the layout on a per-page basis, by adding a special layout variable to your page:title: This is the page title. Layout: another.template ---- <p>This is my page body, it uses a different layout!</p>
When you install templer you'll also install a script called templer-generate which is used to initiate a new site. Given a directory name it will create :
- A configuration file.
- A layout.
- Some trivial input pages
From the generated site you can tweak the layout, add your content, and rebuild by merely running templer in the top-level directory.
As we've already seen simple variables can be defined and used within pages. (They can also be defined globally in the templer configuration file. To allow you to set a copyright date, visible to all pages for example.)
The declaration of variables is flexible due to the templer plugin-support, so you can declare variables which are simple strings, or which can contain the output of running shell commands, or even matching file patterns.
The following example uses a file-pattern variable to generate a simple gallery including all images beneath img/:title: This is the title of my page. images: file_glob( "img/*.jpg" ) ---- Here is my page body. Here are the images: <!-- tmpl_loop name='images' --> <p> <img src="<!-- tmpl_var name='file' -->" /> </p> </!-- /tmpl_loop -->
templer is developed and hosted upon Github.com, where you can find both the code and a lot more documentation:
There are packages available for the Wheezy & Jessie release of Debian GNU/Linux in this repository.
Finally if you prefer you can download and install directly from CPAN:~$ perl -MCPAN -e shell cpan> install App::Templer