NAME

SQLite::Work::Template - template stuff for SQLite::Work

VERSION

This describes version 0.03 of SQLite::Work::Template.

SYNOPSIS

use SQLite::Work::Template;

my $tobj = SQLite::Work::Template->new(%new_args);

$out =~ s/{([^}]+)}/$tobj->fill_in(row_hash=>$row_hash,targ=>$1)/eg;

DESCRIPTION

This is the template stuff used for SQLite::Work templates (for rows, headers and groups).

The format is as follows:

{$colname}

A variable; will display the value of the column, or nothing if that value is empty.

{?colname stuff [$colname] more stuff}

A conditional. If the value of 'colname' is not empty, this will display "stuff value-of-column more stuff"; otherwise it displays nothing.

{?col1 stuff [$col1] thing [$col2]}

This would use both the values of col1 and col2 if col1 is not empty.

{?colname stuff [$colname] more stuff!!other stuff}

A conditional with "else". If the value of 'colname' is not empty, this will display "stuff value-of-column more stuff"; otherwise it displays "other stuff".

This version can likewise use multiple columns in its display parts.

{?col1 stuff [$col1] thing [$col2]!![$col3]}

CLASS METHODS

new

my $obj = SQLite::Work::Template->new();

Make a new template object.

METHODS

fill_in

Fill in the given value.

    $val = $obj->fill_in(targ=>$targ,
	row_hash=>$row_hashref,
	show_cols=>\%show_cols);

Where 'targ' is the target value, which is either a variable target, or a conditional target.

The 'row_hash' is a hash containing names and values.

The 'show_cols' is a hash saying which of these "column names" ought to be displayed, and which suppressed.

This can do templating by using the exec ability of substitution, for example:

$out =~ s/{([^}]+)}/$tobj->fill_in(row_hash=>$row_hash,targ=>$1)/eg;

get_value

$val = $obj->get_value(val_id=>$val_id, row_hash=>$row_hashref, show_cols=>\%show_cols);

Get and format the given value.

convert_value

    my $val = $obj->convert_value(value=>$val,
	format=>$format,
	name=>$name);

Convert a value according to the given formatting directive.

Directives are:

upper

Convert to upper case.

lower

Convert to lower case.

int

Convert to integer

float

Convert to float.

string

Return the value with no change.

truncatenum

Truncate to num length.

dollars

Return as a dollar value (float of precision 2)

percent

Show as if the value is a percentage.

title

Put any trailing ,The or ,A at the front (as this is a title)

comma_front

Put anything after the last comma at the front (as with an author name)

month

Convert the number value to a month name.

nth

Convert the number value to a N-th value.

url

Convert to a HTML href link.

email

Convert to a HTML mailto link.

hmail

Convert to a "humanized" version of the email, with the @ and '.' replaced with "at" and "dot"

html

Convert to simple HTML (simple formatting)

proper

Convert to a Proper Noun.

wordsnum

Give the first num words of the value.

alpha

Convert to a string containing only alphanumeric characters (useful for anchors or filenames)

namedalpha

Similar to 'alpha', but prepends the 'name' of the value. Assumes that the name is only alphanumeric.

simple_html

$val = $obj->simple_html($val);

Do a simple HTML conversion of the value. bold, italic, <br>

REQUIRES

Test::More

INSTALLATION

To install this module, run the following commands:

perl Build.PL
./Build
./Build test
./Build install

Or, if you're on a platform (like DOS or Windows) that doesn't like the "./" notation, you can do this:

perl Build.PL
perl Build
perl Build test
perl Build install

In order to install somewhere other than the default, such as in a directory under your home directory, like "/home/fred/perl" go

perl Build.PL --install_base /home/fred/perl

as the first step instead.

This will install the files underneath /home/fred/perl.

You will then need to make sure that you alter the PERL5LIB variable to find the modules, and the PATH variable to find the script.

Therefore you will need to change: your path, to include /home/fred/perl/script (where the script will be)

PATH=/home/fred/perl/script:${PATH}

the PERL5LIB variable to add /home/fred/perl/lib

PERL5LIB=/home/fred/perl/lib:${PERL5LIB}

SEE ALSO

perl(1). DBI DBD::SQLite

BUGS

Please report any bugs or feature requests to the author.

AUTHOR

Kathryn Andersen (RUBYKAT)
perlkat AT katspace dot com
http://www.katspace.com

COPYRIGHT AND LICENCE

Copyright (c) 2005 by Kathryn Andersen

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