NAME

Bricklayer::Templater - yet another templating system. Pure perl, highly flexible with very few dependencies.

SYNOPSIS

use Bricklayer::Templater;
use Cwd;

my $cwd = cwd();

# create a new templater with a context object and a working directory
my $t = Bricklayer::Templater->new($context, $cwd);

# run the templater on a named template
$t->run_templater('name_of_template');

# retrieve the page after running templater on it.
my $page = $t->_page();

DESCRIPTION

Bricklayer::Templater began as a way to make a simple easy to use flexible templating engine. It has evolved over time but still retains that flexibility, simplicity, and ease of use.

It is based on template tags and is completely configurable as far as how those tags are identified. The default is <BKtagname attrib="something" ></BKtagname> you can specify different start and end brackets and identifiers (the BK in the above tags)

Configuring Templater options

Changing start_bracket for the template objects tags $t->start_bracket('['); #default is <

Change the end_bracket for the template objects tags $t->end_bracket(']'); #default is >

Change the identifier for the templater objects tags $t->identifier('?'); #default is BK

Change the template extension $t->ext('tmpl'); #default is txml

There are two primary purposes for this configurability. One is to for aesthetic reasons, the other is for multipass templating. Multipass templating is possible by running the template once for one configuration of tags then again on the results with a different configuration of tags.

Running a Template

There are two ways you can run a template. The first and easiest is to call $t->run_templater('template_name'); This will look in your working directory for a template by that name and with the configured extension and then run it.

The template will be stored in $t->_page() or be published with the publish hook provided by you if you sub classed the engine.

The publish method.

There is one method you probably want to override if you subclass this engine. publish() This method will be called by handlers with their results. If you don't override it then the default is to append those results to the _page attribute of the template object.

The rest of the API

load_template_file

my $file = $t->load_template_file('template_name') loads a template file from the working directory there are two ways to specify the template name.

path/name syntax

$t->load_template_file('relative/path/template_name')

name::space syntax (perl like)

$t->load_template_file('name::space::template_name')

$t->run_sequencer($file)

run_sequencer runs the sequencer on the text in $file. The results of the template run will be stored wherever publish() puts it.

clear

$t->clear() Clears the contents of _page() it's a convenience method. If you override the publish method you might want to override this one too if you need it.

Authors

Jeremy A. Wall <Jeremy@MarzhillStudios.com>

BUGS

Like any Module of sufficient complexity there are probably some things I missed.
See http://rt.cpan.org to report and view bugs

COPYRIGHT (C) Copyright 2007 Jeremy Wall <Jeremy@Marzhillstudios.com>

This program is free software you can redistribute it and/or modify it under the same terms as Perl itself.

See http://www.Perl.com/perl/misc/Artistic.html