NAME
templer - A static-site generator, written in perl.
SYNOPSIS
templer [options]
Help Options:
--help Show the help information for this script.
--manual Read the manual for this script.
Flags
--config=I<FILE> Use I<FILE> as global config file
--force Force a rebuild of all pages/assets
--in-place Specify we're processing pages in-place, ignoring the output dir.
--quiet Don't show output.
--verbose Be noisy during the execution.
ABOUT
Templer is the static-site generator utility I use for my websites.
Templer flexible with input pages, and allows variables to be defined on a global or per-page basis, and then inserted into the output.
Given a single template a complete site may be generated with an arbitrary number of pages, each sharing a common look and feel. If required you can define a range of templates and select which to use on a per-page basis.
We allow variable interpolation, loops, and conditional expansion in the generated output via the use of the HTML::Template module.
The name? It stuck. Initially I was thinking "templator" and "Templer" popped into my mind, via Knights Templer.
Live Usage
This code is in use on several domains I host/maintain:
Originally I had one utility to generate the HTML for each of those sites, called 'webgen'. Over time this single version divererged into several, as I made ad-hoc changes to cope with the different sites.
Templer was created to replace my previous script, ensuring that each of the site-specific requirements would continue to be satisified, on that basis it should be generally flexible and usable by others.
Site Structure
A templer-based site consists of a configuration file templer.cfg
and an input directory. Input files are processed with HTML::Template, to expand any variables set in the pages themselves, or in the global template.
Once page-content is expanded it is then inserted into a global layout template.
There are two modes of operation when it comes to processing files:
- "In-place"
-
Files are processed and the suffix is replaced with .html
- Output Path
-
Files are generated in a distinct output-tree, and any static assets such as JPG, GIF, PNG, CSS, and JS files are copied across too.
This allows you to run in-place in your ~/public_html
directory or to setup an output path which is later synced to your final/live location.
Code Layout
The implementation uses several simple classes, mostly as wrappers around variable parsing:
- Templer::Global
-
This contains the parsing code for the global configuration file, which is located at the top-level directory of the site. (It must be named
templer.cfg
). - Templer::Plugin::Factory
-
A class-factory for loading/invoking plugin methods.
- Templer::Site
-
Given an input directory this module finds and returns
Templer::Site::Asset
andTempler::Site::Page
objects for each file present. This module is also where all the actual building occurs. - Templer::Site::Asset
-
An item which requires zero expansion. Media, javascript, etc.
- Templer::Site::Page
-
A page which requires template expansion.
- Templer::Timer
-
A utility to report upon time-durations.
Note #1: The command-line options override those specified in the global object.
Note #2: The global object has sensible defaults.
Questions / Bug Reports
The code is developed and hosted on gitub in the following location:
Please raise any issues in the tracker there.
LICENSE
This module is free software; you can redistribute it and/or modify it under the terms of either:
a) the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version, or
b) the Perl "Artistic License".
AUTHOR
Steve
--
http://www.steve.org.uk/
LICENSE
Copyright (c) 2012-2015 by Steve Kemp. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The LICENSE file contains the full text of the license.