Templer::Site - An interface to a templer site.


    use strict;
    use warnings;

    use Templer::Site;

    # Create the helper.
    my $site   = Templer::Site->new( suffix => ".skx" );

    # Get the pages/assets.
    my @pages  = $site->pages();
    my @assets = $site->assets();


This class encapsulates a site. A site is comprised of "pages" and "assets".


Pages are things which are template expanded. These are represented by instances of the Templer::Site::Page class.


Assets are files that are merely copied from the input directory to the output path. If we're running in "in-place" mode then they are ignored.

Assets are represented by instances of the Templer::Site::Assets class.

This class contains helpers for finding and returning arrays of both such objects, and the code necessary to work with them and build a site.


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".


Steve Kemp <>


Copyright (C) 2012-2015 Steve Kemp <>.

This library is free software. You can modify and or distribute it under the same terms as Perl itself.



Constructor, this should be given a hash of arguments for example:


The input directory to process.


The output directory to write to.


The suffixe that will discover "Pages", for example '.skx', or '.tmplr'.


Ensure that the input directory exists.

Create the output directory if we're not running in-place.

Create array of destination files.


A site comprises of a collection of pages and a collection of static resources which aren't touched/modified - these are "assets".

Return a Templer::Site::Page object for each page we've found.

NOTE We don't process pages with a "." prefix, i.e. dotfiles.


A site comprises of a collection of pages and a collection of static resources which aren't touched/modified - these are "assets".

Return a Templer::Site::Asset object for each asset we find.

NOTE We include files which have a "." prefix here - to correctly copy files such as ".htpasswd", ".htaccess", etc.


Internal method to find files beneath the given directory and return a new object for each one.

We assume that the object constructor receives a hash as its sole argument with the key "file" containing the file path.


Build the site.

This is the method which does all the page-expansion, site-generation, etc.

The return value is the count of pages built.


Copy all assets from the input directory to the output directory.

This method will use tar to do so semi-efficiently.


Delete all files from output directory which do not come from the input directory.


Store/update a key/value pair in our internal store.

This allows the values passed in the constructor to be updated/added to.


Get all known key + value pairs from our store.

This is called to get all global variables for template interpolation as part of the build. (The global variables and the per-page variables are each fetched and expanded via plugins prior to getting sent to the HTML::Template object.).


Get a single value from our store of variables.