Template::Library::Splash - Template library for building stylish HTML user interfaces
DESCRIPTION
NOTE: This documentation is incomplete, incorrect and outdated.
The Splash! library is still evolving and subject to change. See
the examples for a much more recent and accurate demonstration of
use.
Introduction
The 'Splash' template library is distributed as part of the Template
Toolkit. It can be found in the 'templates' sub-directory of the
installation directory.
/your/tt2/installation
|
+-- docs
| ...
|
+-- images
| ...
|
+-- examples
| ...
|
+-- templates
|
+-- html
| ...
+-- pod
| ...
+-- splash <<<< YOU ARE HERE
...
To use the Splash library, you first need to tell the Template Toolkit
where to find the template files.
use Template;
my $tt2 = Template->new({
INCLUDE_PATH => '/usr/local/tt2/templates',
});
For a portable way to determine the installation 'templates' directory,
you can use the "Template::Config->instdir()" class method.
use Template;
my $tt2 = Template->new({
INCLUDE_PATH => Template::Config->instdir('templates'),
});
Note that you should set the INCLUDE_PATH to the 'templates' directory
as shown here and don't be tempted to set the INCLUDE_PATH to
'templates/splash'. Many of the Splash! components use elements in
the 'html' directory and contain directives of the form:
[% INCLUDE html/something %].
Configuration
The 'splash/config' template defines a 'splash' hash array which
contains numerous configuration items for the Splash library. You
must PROCESS this template to ensure that the hash definition is
imported into your calling template. An INCLUDE is not sufficient as
it localises variables and prevents the 'splash' hash array from
existing outside the splash/config template.
[% PROCESS splash/config %]
Alternately, you can define the splash/config template as a PRE_PROCESS
item when you create the Template processor.
You can modify the default configuration by creating your own
PRE_PROCESS config file which loads the 'splash/config' and then
tweaks the settings to your own preferences.
[% # load the 'splash' configuration
PROCESS splash/config;
# tweak values to personal preferences
splash.images = '/~abw/tt2/images/splash'
splash.select.col = 'leaf'
splash.unselect.col = 'bud'
%]
The splash/config file includes some instructional comments on
things you might like to tweak.
Colours
The Splash! library uses the colours defined in the html/rgb template.
The 'rgb' hash defined therein is imported as the 'splash.rgb' hash.
[% INCLUDE splash/box col='grey75' %]
See the examples for further enlightenment on using colour.
Style
There are two very primitive ``styles'' implemented called ``select'' and
``unselect''. These are used to indicate which item on a menu is
selected, for example. Each style defines characteristics like
background colour, font face, size and colour, text alignment, and so
on.
The styles are implemented as hashes within the 'splash' hash. Many
of the components respond to a 'style' variable being set and you can
pass a direct reference to splash.select or splash.unselect (or your
own styles). e.g.
[% INCLUDE splash/button
content = "Unselected"
style = splash.unselect
%]
[% INCLUDE splash/button
content ="Selected"
style = splash.select
%]
Alternately, you can use the 'select' variable to indicate either
of the inbuilt styles: splash.select or splash.unselect.
[% INCLUDE splash/button
content = "Unselected"
select = 0
%]
[% INCLUDE splash/button
content = "Selected"
select = 1
%]
COMPONENT TEMPLATES
This section describes some of the component templates in the Splash!
library. This documentation is incomplete and may also be inaccurate
in places. The examples in the 'examples' directory are likely to be
a much better reference.
splash/text
Simple template to format text according to a selected/unselected style,
adding links, etc.
Flag to default the style to splash.select (select == true value) or
splash.unselect (select == false value).
width
Width in absolute pixels (e.g. '100') or as a percentage (e.g. '50%').
The following items default to the relevant style values:
col (style.col.text)
textcol (style.col.text)
font (style.font.face)
size (style.font.size)
bold (style.font.bold)
width (style.button.width)
align (style.button.align)
splash/bar
Creates a bar with rounded corners at either the top or bottom, and
square corners on the other. Default has rounded at the top, set
'invert' to select bottom.