NAME

Template::TAL::TALES - parse TALES strings

SYNOPSIS

my $string = "path:/foo/bar/0/baz";
my $value = Template::TAL::TALES->value( $string );

DESCRIPTION

TALES is the recommended syntax for TAL expressions. It is an extensible syntax that allows you to define any number of expression types and use them together. See http://www.zope.org/Wikis/DevSite/Projects/ZPT/TALES for the spec.

This module is a Perl TALES processor, as well as providing a useful split utility.

METHODS

split( string )

commands in 'string' can be split by ';' characters, with raw semicolons represented as ';;'. This command splits the string on the semicolons, and de-escapes the ';;' pairs. For instance:

foo; bar; baz;; narf

splits to:

['foo', 'bar', 'baz; narf']

Not technically part of TALES, I think, but really useful for TAL anyway.

process_path( path, context, context, context.. )

follows the path into the passed contexts. Will return the value of the key if it is found in any of the contexts, searching first to last, or undef if not. Path is something like

/foo/bar/0/baz/narf

and this will map to (depending on the object types in the context)

$context->{foo}->bar()->[0]->{baz}->narf();
process_string( string, context, context, .. )

interprets 'string' as a string, and returns it. This includes variable interpolation from the contexts, for instance, the string

This is my ${weapon}!

Where the context is

{ weapon => "boomstick' }

will be interpolated properly. Both ${this} and $this style of placeholder will be interpolated.

process_not( value, context )

Evaluates 'value' as a TALES string in the context, and return the boolean value that is its opposite. eg

not:string:0 - true
not:/foo/bar - the opposite of /foo/bar
value( expression, context, context, .. )

parse a TALES expression in the first param, such as

string:Hello there
path:/a/b/c

using the passed contexts (in order) to look up path values. Contexts should be hashes, and we will look in each context for a defined key of the given path until we find one.

(note - I need the multiple contexts code because TAL lets you set globals in define statements, so I need a local context, and a global context)

COPYRIGHT

Written by Tom Insam, Copyright 2005 Fotango Ltd. All Rights Reserved

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