tt2
Sponsored Links
Sponsored Links
Secleted [ 0 ] software to compare
Results 1 - 15 of about 15
PerlPoint::Template::TT2 0.02
PerlPoint::Template::TT2 is a beta of a PerlPoint template processor for Template Toolkit 2 layouts. more>>
PerlPoint::Template::TT2 is a beta of a PerlPoint template processor for Template Toolkit 2 layouts.
METHODS
new()
Parameters:
class
The class name.
Returns: the new object.
Example:
# start page
$result.="nnnn";
# begin header
$result.="nnnn";
# header contents: this was added to the traditional list of template files
$result.=$me->_processTemplate(join(/, $tdir, $options->{$toc ? header_toc_template : header_template}), $toc ? 1 : $params{page});
# complete header
$result.="nnnn";
# begin body
$result.="nnnn";
# now the body contents: start with top part
$result.=$me->_processTemplate(join(/, $tdir, $options->{$toc ? top_toc_template : top_template}), $toc ? 1 : $params{page});
# add navigation, if necessary
$result.=$me->_processTemplate(join(/, $tdir, $options->{$toc ? nav_toc_template : nav_template}), $toc ? 1 : $params{page})
if exists $options->{$toc ? nav_toc_template : nav_template};
# include data (for TOCs, make sure not to add a standard TOC if the tree applet is used
# - this should be more generic in case users use other methods ...)
$result.=$toc ? $result=~/
<<lessMETHODS
new()
Parameters:
class
The class name.
Returns: the new object.
Example:
# start page
$result.="nnnn";
# begin header
$result.="nnnn";
# header contents: this was added to the traditional list of template files
$result.=$me->_processTemplate(join(/, $tdir, $options->{$toc ? header_toc_template : header_template}), $toc ? 1 : $params{page});
# complete header
$result.="nnnn";
# begin body
$result.="nnnn";
# now the body contents: start with top part
$result.=$me->_processTemplate(join(/, $tdir, $options->{$toc ? top_toc_template : top_template}), $toc ? 1 : $params{page});
# add navigation, if necessary
$result.=$me->_processTemplate(join(/, $tdir, $options->{$toc ? nav_toc_template : nav_template}), $toc ? 1 : $params{page})
if exists $options->{$toc ? nav_toc_template : nav_template};
# include data (for TOCs, make sure not to add a standard TOC if the tree applet is used
# - this should be more generic in case users use other methods ...)
$result.=$toc ? $result=~/
Download (0.006MB)
Added: 2007-02-15 License: Perl Artistic License Price:
981 downloads
OpenInteract2::TT2::Plugin 1.99_06
OpenInteract2::TT2::Plugin is a Perl module for custom OpenInteract functionality in templates. more>>
OpenInteract2::TT2::Plugin is a Perl module for custom OpenInteract functionality in templates.
SYNOPSIS
# Create the TT object with the OI plugin
my $template = Template->new(
PLUGINS => { OI => OpenInteract2::TT2::Plugin }, ... );
my ( $output );
$template->process( package::template, %params, $output );
# In the template (brief examples, see below for more)
Here is what the plugin can do:
< ul>< li>[% OI.show_all_actions.join( "n < li>" ) -%]< /ul>
Here are plugins available to you:
[% OI.show_all_plugins.keys.sort.join( , ) %]
Here are all the parameters passed to the request:
[% OI.request_param.sort.join( , ) %]
And the value of a particular parameter:
last name: [% OI.request_param( last_name ) %]
[% OI.action_execute( error_display, error_msg = error_msg ) -%]
# Note that you can also use the MSG function
[% OI.msg( mypage.intro, OI.login.full_name ) %]
# Note that you can also use the LH variable
[% mh = OI.msg_handle %]
[% mh.maketext( mypage.intro, OI.login.full_name ) %]
[% mh.maketext( mypage.learnmore ) %]
[% OI.box_add( contact_tools_box, title = Contact Tools,
weight = 2 ) -%]
[% object_info = OI.object_description( object ) %]
This is a [% object_info.name %] object.
Is the object in the class?
[% OI.class_isa( object, SPOPS::DBI ) ? yes : no %]
Is the SPOPS object writable?
[% IF OI.can_write( object ) %]Youre special![% END %]
[% action = OI.action %]
Action that called this template: [% action.name %]
Security for action:
[% action.security_level %] found,
[% action.security_required %] required
Properties of action:
[% action_prop = action.properties %]
[% FOREACH key = action_prop.keys %]
[% key %] = [% action_prop.$key %]
[% END %]
Parameters of action:
[% action_param = action.param %]
[% FOREACH key = action_param.keys %]
[% key %] = [% action_param.$key %]
[% END %]
Today is [% OI.date_format( now, %Y-%m-%d %l:%M %p ) %] the
[% OI.date_format( now, %j ) %] day of the year
[% d = OI.date_into_object( object.updated_on, %Y-%m-%d ) -%]
[% OI.action_execute( date_select, month_value = d.month,
day_value = d.day,
year_value = d.year, blank = 1,
field_prefix = updated_on ) -%]
[% INCLUDE form_checkbox( name = is_in_print,
value = TRUE,
is_checked = OI.as_boolean( book.is_in_print ) ) -%]
Is in print? [% OI.as_boolean_label( book.is_in_print ) %]
Is in print? [% OI.as_boolean_label( book.is_in_print, You betcha, No way ) %]
[% OI.limit_string( object.description, 30 ) %]
var person_last_name = [% OI.javascript_quote( person.last_name ) %];
[% OI.limit_sentences( news.news_item, 3 ) %]
[% score = grade.score / test.total %]
Your grade is: [% OI.percent_format( score ) %]
You have [% OI.money_format( account.balance ) %] left to spend.
Hello [% OI.uc_first( person.first_name ) %]
You are important so I must speak to you loudly [% OI.uc( person.last_name ) %]
Item: [% OI.html_decode( news.news_item ) %]
# Add parameters to an existing URL
[% display_no_template_url = OI.add_params_to_url( my_path, no_template = yes ) %]
# Works, but not as useful...
[% edit_url = OI.make_url( BASE = /User/show/, user_id = OI.login.user_id,
edit = 1, show_all = yes ) %]
# Preferred way to generate URLs for actions
[% edit_url = OI.make_url( ACTION = user, TASK = show,
user_id = OI.login.user_id,
edit = 1, show_all = yes ) %]
[% image_url = OI.make_url( IMAGE = /images/foo.gif ) %]
[% static_url = OI.make_url( STATIC = /generated/report-q1-2003.pdf ) %]
[% theme = OI.theme_properties %]
Background color of page: [% theme.bgcolor %]
[% new_theme = OI.theme_fetch( 5 ) %]
Background color of page from other theme: [% new_theme.bgcolor %]
[% IF OI.logged_in -%]
Hello [% OI.login.full_name %].
Your groups are: [% OI.login_group.join( , ) -%]
[% ELSE -%]
You are not logged in.
[% END -%]
Your last search: [% OI.session.latest_search %]
< a href="[% OI.return_url %]">Refresh< /a>
[% IF object.tmp_security_level >= OI.security_level.write -%]
you can edit this object!
[% END %]
<<lessSYNOPSIS
# Create the TT object with the OI plugin
my $template = Template->new(
PLUGINS => { OI => OpenInteract2::TT2::Plugin }, ... );
my ( $output );
$template->process( package::template, %params, $output );
# In the template (brief examples, see below for more)
Here is what the plugin can do:
< ul>< li>[% OI.show_all_actions.join( "n < li>" ) -%]< /ul>
Here are plugins available to you:
[% OI.show_all_plugins.keys.sort.join( , ) %]
Here are all the parameters passed to the request:
[% OI.request_param.sort.join( , ) %]
And the value of a particular parameter:
last name: [% OI.request_param( last_name ) %]
[% OI.action_execute( error_display, error_msg = error_msg ) -%]
# Note that you can also use the MSG function
[% OI.msg( mypage.intro, OI.login.full_name ) %]
# Note that you can also use the LH variable
[% mh = OI.msg_handle %]
[% mh.maketext( mypage.intro, OI.login.full_name ) %]
[% mh.maketext( mypage.learnmore ) %]
[% OI.box_add( contact_tools_box, title = Contact Tools,
weight = 2 ) -%]
[% object_info = OI.object_description( object ) %]
This is a [% object_info.name %] object.
Is the object in the class?
[% OI.class_isa( object, SPOPS::DBI ) ? yes : no %]
Is the SPOPS object writable?
[% IF OI.can_write( object ) %]Youre special![% END %]
[% action = OI.action %]
Action that called this template: [% action.name %]
Security for action:
[% action.security_level %] found,
[% action.security_required %] required
Properties of action:
[% action_prop = action.properties %]
[% FOREACH key = action_prop.keys %]
[% key %] = [% action_prop.$key %]
[% END %]
Parameters of action:
[% action_param = action.param %]
[% FOREACH key = action_param.keys %]
[% key %] = [% action_param.$key %]
[% END %]
Today is [% OI.date_format( now, %Y-%m-%d %l:%M %p ) %] the
[% OI.date_format( now, %j ) %] day of the year
[% d = OI.date_into_object( object.updated_on, %Y-%m-%d ) -%]
[% OI.action_execute( date_select, month_value = d.month,
day_value = d.day,
year_value = d.year, blank = 1,
field_prefix = updated_on ) -%]
[% INCLUDE form_checkbox( name = is_in_print,
value = TRUE,
is_checked = OI.as_boolean( book.is_in_print ) ) -%]
Is in print? [% OI.as_boolean_label( book.is_in_print ) %]
Is in print? [% OI.as_boolean_label( book.is_in_print, You betcha, No way ) %]
[% OI.limit_string( object.description, 30 ) %]
var person_last_name = [% OI.javascript_quote( person.last_name ) %];
[% OI.limit_sentences( news.news_item, 3 ) %]
[% score = grade.score / test.total %]
Your grade is: [% OI.percent_format( score ) %]
You have [% OI.money_format( account.balance ) %] left to spend.
Hello [% OI.uc_first( person.first_name ) %]
You are important so I must speak to you loudly [% OI.uc( person.last_name ) %]
Item: [% OI.html_decode( news.news_item ) %]
# Add parameters to an existing URL
[% display_no_template_url = OI.add_params_to_url( my_path, no_template = yes ) %]
# Works, but not as useful...
[% edit_url = OI.make_url( BASE = /User/show/, user_id = OI.login.user_id,
edit = 1, show_all = yes ) %]
# Preferred way to generate URLs for actions
[% edit_url = OI.make_url( ACTION = user, TASK = show,
user_id = OI.login.user_id,
edit = 1, show_all = yes ) %]
[% image_url = OI.make_url( IMAGE = /images/foo.gif ) %]
[% static_url = OI.make_url( STATIC = /generated/report-q1-2003.pdf ) %]
[% theme = OI.theme_properties %]
Background color of page: [% theme.bgcolor %]
[% new_theme = OI.theme_fetch( 5 ) %]
Background color of page from other theme: [% new_theme.bgcolor %]
[% IF OI.logged_in -%]
Hello [% OI.login.full_name %].
Your groups are: [% OI.login_group.join( , ) -%]
[% ELSE -%]
You are not logged in.
[% END -%]
Your last search: [% OI.session.latest_search %]
< a href="[% OI.return_url %]">Refresh< /a>
[% IF object.tmp_security_level >= OI.security_level.write -%]
you can edit this object!
[% END %]
Download (0.91MB)
Added: 2006-12-14 License: Perl Artistic License Price:
1044 downloads
Template::Plugin::Datum 0.02
Template::Plugin::Datum is a Perl module with TT2 plugin that converts international date format to German date format. more>>
Template::Plugin::Datum is a Perl module with TT2 plugin that converts international date format to German date format.
SYNOPSIS
[% USE Datum %]
von: [% 20030101 | datum %] -> 01.01.2003
bis: [% 2003-12-31 | datum %] -> 31.12.2003
Zeitstempel: [% 20031212143000 | datum %] -> 12.12.2003 14:30:00
This plugin converts international date format (year-month-day) to German date format (day.month.year).
Recognized formats are:
yyyy-mm-dd (2003-12-31)
yyyymmdd (20031231)
yyyymmddHHMMSS (20031231143000) date and time
<<lessSYNOPSIS
[% USE Datum %]
von: [% 20030101 | datum %] -> 01.01.2003
bis: [% 2003-12-31 | datum %] -> 31.12.2003
Zeitstempel: [% 20031212143000 | datum %] -> 12.12.2003 14:30:00
This plugin converts international date format (year-month-day) to German date format (day.month.year).
Recognized formats are:
yyyy-mm-dd (2003-12-31)
yyyymmdd (20031231)
yyyymmddHHMMSS (20031231143000) date and time
Download (0.002MB)
Added: 2006-09-20 License: Perl Artistic License Price:
1129 downloads
Template::Tools::ttree 2.19
Template::Tools::ttree module can process entire directory trees of templates. more>>
Template::Tools::ttree module can process entire directory trees of templates.
SYNOPSIS
ttree [options] [files]
The ttree script is used to process entire directory trees containing template files. The resulting output from processing each file is then written to a corresponding file in a destination directory. The script compares the modification times of source and destination files (where they already exist) and processes only those files that have been modified. In other words, it is the equivalent of make for the Template Toolkit.
It supports a number of options which can be used to configure behaviour, define locations and set Template Toolkit options. The script first reads the .ttreerc configuration file in the HOME directory, or an alternative file specified in the TTREERC environment variable. Then, it processes any command line arguments, including any additional configuration files specified via the -f (file) option.
The .ttreerc Configuration File
When you run ttree for the first time it will ask you if you want it to create a .ttreerc file for you. This will be created in your home directory.
$ ttree
Do you want me to create a sample .ttreerc file for you?
(file: /home/abw/.ttreerc) [y/n]: y
/home/abw/.ttreerc created. Please edit accordingly and re-run ttree
The purpose of this file is to set any global configuration options that you want applied every time ttree is run. For example, you can use the ignore and copy option to provide regular expressions that specify which files should be ignored and which should be copied rather than being processed as templates. You may also want to set flags like verbose and recurse according to your preference.
A minimal .ttreerc:
# ignore these files
ignore = b(CVS|RCS)b
ignore = ^#
ignore = ~$
# copy these files
copy = .(gif|png|jpg|pdf)$
# recurse into directories
recurse
# provide info about whats going on
verbose
In most cases, youll want to create a different ttree configuration file for each project youre working on. The cfg option allows you to specify a directory where ttree can find further configuration files.
cfg = /home/abw/.ttree
The -f command line option can be used to specify which configuration file should be used. You can specify a filename using an absolute or relative path:
$ ttree -f /home/abw/web/example/etc/ttree.cfg
$ ttree -f ./etc/ttree.cfg
$ ttree -f ../etc/ttree.cfg
If the configuration file does not begin with / or . or something that looks like a MS-DOS absolute path (e.g. C:etcttree.cfg) then ttree will look for it in the directory specified by the cfg option.
$ ttree -f test1 # /home/abw/.ttree/test1
The cfg option can only be used in the .ttreerc file. All the other options can be used in the .ttreerc or any other ttree configuration file. They can all also be specified as command line options.
Remember that .ttreerc is always processed before any configuration file specified with the -f option. Certain options like lib can be used any number of times and accumulate their values.
For example, consider the following configuration files:
/home/abw/.ttreerc:
cfg = /home/abw/.ttree
lib = /usr/local/tt2/templates
/home/abw/.ttree/myconfig:
lib = /home/abw/web/example/templates/lib
When ttree is invoked as follows:
$ ttree -f myconfig
the lib option will be set to the following directories:
/usr/local/tt2/templates
/home/abw/web/example/templates/lib
Any templates located under /usr/local/tt2/templates will be used in preference to those located under /home/abw/web/example/templates/lib. This may be what you want, but then again, it might not. For this reason, it is good practice to keep the .ttreerc as simple as possible and use different configuration files for each ttree project.
<<lessSYNOPSIS
ttree [options] [files]
The ttree script is used to process entire directory trees containing template files. The resulting output from processing each file is then written to a corresponding file in a destination directory. The script compares the modification times of source and destination files (where they already exist) and processes only those files that have been modified. In other words, it is the equivalent of make for the Template Toolkit.
It supports a number of options which can be used to configure behaviour, define locations and set Template Toolkit options. The script first reads the .ttreerc configuration file in the HOME directory, or an alternative file specified in the TTREERC environment variable. Then, it processes any command line arguments, including any additional configuration files specified via the -f (file) option.
The .ttreerc Configuration File
When you run ttree for the first time it will ask you if you want it to create a .ttreerc file for you. This will be created in your home directory.
$ ttree
Do you want me to create a sample .ttreerc file for you?
(file: /home/abw/.ttreerc) [y/n]: y
/home/abw/.ttreerc created. Please edit accordingly and re-run ttree
The purpose of this file is to set any global configuration options that you want applied every time ttree is run. For example, you can use the ignore and copy option to provide regular expressions that specify which files should be ignored and which should be copied rather than being processed as templates. You may also want to set flags like verbose and recurse according to your preference.
A minimal .ttreerc:
# ignore these files
ignore = b(CVS|RCS)b
ignore = ^#
ignore = ~$
# copy these files
copy = .(gif|png|jpg|pdf)$
# recurse into directories
recurse
# provide info about whats going on
verbose
In most cases, youll want to create a different ttree configuration file for each project youre working on. The cfg option allows you to specify a directory where ttree can find further configuration files.
cfg = /home/abw/.ttree
The -f command line option can be used to specify which configuration file should be used. You can specify a filename using an absolute or relative path:
$ ttree -f /home/abw/web/example/etc/ttree.cfg
$ ttree -f ./etc/ttree.cfg
$ ttree -f ../etc/ttree.cfg
If the configuration file does not begin with / or . or something that looks like a MS-DOS absolute path (e.g. C:etcttree.cfg) then ttree will look for it in the directory specified by the cfg option.
$ ttree -f test1 # /home/abw/.ttree/test1
The cfg option can only be used in the .ttreerc file. All the other options can be used in the .ttreerc or any other ttree configuration file. They can all also be specified as command line options.
Remember that .ttreerc is always processed before any configuration file specified with the -f option. Certain options like lib can be used any number of times and accumulate their values.
For example, consider the following configuration files:
/home/abw/.ttreerc:
cfg = /home/abw/.ttree
lib = /usr/local/tt2/templates
/home/abw/.ttree/myconfig:
lib = /home/abw/web/example/templates/lib
When ttree is invoked as follows:
$ ttree -f myconfig
the lib option will be set to the following directories:
/usr/local/tt2/templates
/home/abw/web/example/templates/lib
Any templates located under /usr/local/tt2/templates will be used in preference to those located under /home/abw/web/example/templates/lib. This may be what you want, but then again, it might not. For this reason, it is good practice to keep the .ttreerc as simple as possible and use different configuration files for each ttree project.
Download (0.75MB)
Added: 2007-08-06 License: Perl Artistic License Price:
809 downloads
Template::Library::HTML 2.15
Template::Library::HTML is a template library for building basic HTML pages. more>>
Template::Library::HTML is a template library for building basic HTML pages.
NOTE: This documentation is incomplete and may be incorrect in places. The html template library is distributed as part of the Template Toolkit. It can be found in the templates sub-directory of the installation directory.
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),
});
You should now be able to access the html library as, for example:
[% INCLUDE html/header %]
Note that some of the more basic elements dont give you much more than the raw HTML tags. In many cases you might be well advised to stick to regular HTML rather than complicating matters by the use of template elements.
e.g.
< table >
. . .
< /table >
vs
[% WRAPPER html/table %]
. . .
[% END %]
However, the use of template elements to generate the underlying HTML does have some important benefits, particularly as the constructs start to get more complicated and more magical.
See the example in the examples sub-directory of the distribution directory for further examples and enlightenment on using this library.
<<lessNOTE: This documentation is incomplete and may be incorrect in places. The html template library is distributed as part of the Template Toolkit. It can be found in the templates sub-directory of the installation directory.
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),
});
You should now be able to access the html library as, for example:
[% INCLUDE html/header %]
Note that some of the more basic elements dont give you much more than the raw HTML tags. In many cases you might be well advised to stick to regular HTML rather than complicating matters by the use of template elements.
e.g.
< table >
. . .
< /table >
vs
[% WRAPPER html/table %]
. . .
[% END %]
However, the use of template elements to generate the underlying HTML does have some important benefits, particularly as the constructs start to get more complicated and more magical.
See the example in the examples sub-directory of the distribution directory for further examples and enlightenment on using this library.
Download (0.76MB)
Added: 2006-09-05 License: GPL (GNU General Public License) Price:
1144 downloads
Template::Library::Splash 2.15
Template::Library::Splash is a template library for building stylish HTML user interfaces. more>>
Template::Library::Splash is a template library for building stylish HTML user interfaces.
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 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 dont 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 %].
<<lessNOTE: 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 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 dont 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 %].
Download (0.76MB)
Added: 2006-09-05 License: Perl Artistic License Price:
1145 downloads
Template::Tutorial::Datafile 2.15
Template::Tutorial::Datafile is a Perl module for creating Data Output Files Using the Template Toolkit. more>>
Template::Tutorial::Datafile is a Perl module for creating Data Output Files Using the Template Toolkit.
This tutorial gives an overview of the Template Toolkit, showing in particular how to use it to read and write data files in various different formats and styles. It was written by Dave Cross and first appeared as a lead article at http://www.perl.com/ earlier in the year (2001).
Introducing the Template Toolkit
There are a number of Perl modules that are universally recognised as The Right Thing To Use for certain tasks. If you accessed a database without using DBI, pulled data from the WWW without using one of the LWP modules or parsed XML without using XML::Parser or one of its subclasses then youd run the risk of being shunned by polite Perl society.
I believe that the year 2000 saw the emergence of another must have Perl module - the Template Toolkit. I dont think Im alone in this belief as the Template Toolkit won the Best New Module award at the Perl Conference last summer. Version 2.0 of the Template Toolkit (known as TT2 to its friends) was recently released to the CPAN.
TT2 was designed and written by Andy Wardley. It was born out of Andys previous templating module, Text::Metatext, in best Fred Brooks plan to throw one away manner; and aims to be the most useful (or, at least, the most used) Perl templating system.
TT2 provides a way to take a file of fixed boilerplate text (the template) and embed variable data within it. One obvious use of this is in the creation of dynamic web pages and this is where a lot of the attention that TT2 has received has been focussed. In this article, I hope to demonstrate that TT2 is just as useful in non-web applications.
<<lessThis tutorial gives an overview of the Template Toolkit, showing in particular how to use it to read and write data files in various different formats and styles. It was written by Dave Cross and first appeared as a lead article at http://www.perl.com/ earlier in the year (2001).
Introducing the Template Toolkit
There are a number of Perl modules that are universally recognised as The Right Thing To Use for certain tasks. If you accessed a database without using DBI, pulled data from the WWW without using one of the LWP modules or parsed XML without using XML::Parser or one of its subclasses then youd run the risk of being shunned by polite Perl society.
I believe that the year 2000 saw the emergence of another must have Perl module - the Template Toolkit. I dont think Im alone in this belief as the Template Toolkit won the Best New Module award at the Perl Conference last summer. Version 2.0 of the Template Toolkit (known as TT2 to its friends) was recently released to the CPAN.
TT2 was designed and written by Andy Wardley. It was born out of Andys previous templating module, Text::Metatext, in best Fred Brooks plan to throw one away manner; and aims to be the most useful (or, at least, the most used) Perl templating system.
TT2 provides a way to take a file of fixed boilerplate text (the template) and embed variable data within it. One obvious use of this is in the creation of dynamic web pages and this is where a lot of the attention that TT2 has received has been focussed. In this article, I hope to demonstrate that TT2 is just as useful in non-web applications.
Download (0.76MB)
Added: 2006-09-14 License: Perl Artistic License Price:
1136 downloads
Template::Alloy 1.004
Template::Alloy is a TT2/3, HT, HTE, Tmpl, and Velocity Engine. more>>
Template::Alloy is a TT2/3, HT, HTE, Tmpl, and Velocity Engine.
SYNOPSIS
Template::Toolkit style usage
my $t = Template::Alloy->new(
INCLUDE_PATH => [/path/to/templates],
);
my $swap = {
key1 => val1,
key2 => val2,
code => sub { 42 },
hash => {a => b},
};
# print to STDOUT
$t->process(my/template.tt, $swap)
|| die $t->error;
# process into a variable
my $out = ;
$t->process(my/template.tt, $swap, $out);
### Alloy uses the same syntax and configuration as Template::Toolkit
HTML::Template::Expr style usage
my $t = Template::Alloy->new(
filename => my/template.ht,
path => [/path/to/templates],
);
my $swap = {
key1 => val1,
key2 => val2,
code => sub { 42 },
hash => {a => b},
};
$t->param($swap);
# print to STDOUT (errors die)
$t->output(print_to => *STDOUT);
# process into a variable
my $out = $t->output;
### Alloy can also use the same syntax and configuration as HTML::Template
Text::Tmpl style usage
my $t = Template::Alloy->new;
my $swap = {
key1 => val1,
key2 => val2,
code => sub { 42 },
hash => {a => b},
};
$t->set_delimiters(#[, ]#);
$t->set_strip(0);
$t->set_values($swap);
$t->set_dir(/path/to/templates);
my $out = $t->parse_file(my/template.tmpl);
my $str = "Foo #[echo $key1]# Bar";
my $out = $t->parse_string($str);
### Alloy uses the same syntax and configuration as Text::Tmpl
Velocity (VTL) style usage
my $t = Template::Alloy->new;
my $swap = {
key1 => val1,
key2 => val2,
code => sub { 42 },
hash => {a => b},
};
my $out = $t->merge(my/template.vtl, $swap);
my $str = "#set($foo 1 + 3) ($foo) ($bar) ($!baz)";
my $out = $t->merge($str, $swap);
<<lessSYNOPSIS
Template::Toolkit style usage
my $t = Template::Alloy->new(
INCLUDE_PATH => [/path/to/templates],
);
my $swap = {
key1 => val1,
key2 => val2,
code => sub { 42 },
hash => {a => b},
};
# print to STDOUT
$t->process(my/template.tt, $swap)
|| die $t->error;
# process into a variable
my $out = ;
$t->process(my/template.tt, $swap, $out);
### Alloy uses the same syntax and configuration as Template::Toolkit
HTML::Template::Expr style usage
my $t = Template::Alloy->new(
filename => my/template.ht,
path => [/path/to/templates],
);
my $swap = {
key1 => val1,
key2 => val2,
code => sub { 42 },
hash => {a => b},
};
$t->param($swap);
# print to STDOUT (errors die)
$t->output(print_to => *STDOUT);
# process into a variable
my $out = $t->output;
### Alloy can also use the same syntax and configuration as HTML::Template
Text::Tmpl style usage
my $t = Template::Alloy->new;
my $swap = {
key1 => val1,
key2 => val2,
code => sub { 42 },
hash => {a => b},
};
$t->set_delimiters(#[, ]#);
$t->set_strip(0);
$t->set_values($swap);
$t->set_dir(/path/to/templates);
my $out = $t->parse_file(my/template.tmpl);
my $str = "Foo #[echo $key1]# Bar";
my $out = $t->parse_string($str);
### Alloy uses the same syntax and configuration as Text::Tmpl
Velocity (VTL) style usage
my $t = Template::Alloy->new;
my $swap = {
key1 => val1,
key2 => val2,
code => sub { 42 },
hash => {a => b},
};
my $out = $t->merge(my/template.vtl, $swap);
my $str = "#set($foo 1 + 3) ($foo) ($bar) ($!baz)";
my $out = $t->merge($str, $swap);
Download (0.14MB)
Added: 2007-06-28 License: Perl Artistic License Price:
849 downloads
Template::Parser::CET 0.04
Template::Parser::CET is a Template::Alloy based parser for the TT2 engine. more>>
Template::Parser::CET is a Template::Alloy based parser for the TT2 engine.
SYNOPSIS
use Template;
use Template::Parser::CET;
my $t = Template->new(
PARSER => Template::Parser::CET->new
);
# you can override all instances of TT
# by any of the following methods
use Template::Parser::CET activate => 1;
# OR
use Template::Parser::CET;
Template::Parser::CET->activate;
# OR
use Template::Config;
$Template::Config::PARSER = Template::Parser::CET;
my $t = Template->new;
Template::Parser::CET provides much or most of the TT3 syntax and runs on the current TT2 engine.
Template::Alloy which was formerly known as CGI::Ex::Template (CET) provides a fast implementation of TT2 and TT3. There are some cases where Template::Toolkit is faster. There are also some cases where shops have custom providers, or custom stashes that require the use of the current TT2 engine. In these cases, Template::Parser::CET provides the best of both worlds - offering TT2 AND TT3 syntax and running on the existing platform making use of all of your current work (In many cases CET should be able to do this anyway).
This module may eventually be made obsolete when the final real Template::Toolkit 3 engine by Andy Wardley is released. But that would only be a good thing. If the TT3 engine doesnt provide full backward compatibility this module will.
CET has provided TT3 features since Spring of 2006 but there has been little reported uptake. The TT3 features/extended syntax are very compelling. For various reasons people chose not to use CET. Now people can use TT2 and get the features of TT3 (through CET) today.
Hopefully Template::Parser::CET and Template::Alloy can be used in the same spirit as Pugs is used for Perl 6. All of the code from CET and Template::Parser::CET are free for use in TT3.
<<lessSYNOPSIS
use Template;
use Template::Parser::CET;
my $t = Template->new(
PARSER => Template::Parser::CET->new
);
# you can override all instances of TT
# by any of the following methods
use Template::Parser::CET activate => 1;
# OR
use Template::Parser::CET;
Template::Parser::CET->activate;
# OR
use Template::Config;
$Template::Config::PARSER = Template::Parser::CET;
my $t = Template->new;
Template::Parser::CET provides much or most of the TT3 syntax and runs on the current TT2 engine.
Template::Alloy which was formerly known as CGI::Ex::Template (CET) provides a fast implementation of TT2 and TT3. There are some cases where Template::Toolkit is faster. There are also some cases where shops have custom providers, or custom stashes that require the use of the current TT2 engine. In these cases, Template::Parser::CET provides the best of both worlds - offering TT2 AND TT3 syntax and running on the existing platform making use of all of your current work (In many cases CET should be able to do this anyway).
This module may eventually be made obsolete when the final real Template::Toolkit 3 engine by Andy Wardley is released. But that would only be a good thing. If the TT3 engine doesnt provide full backward compatibility this module will.
CET has provided TT3 features since Spring of 2006 but there has been little reported uptake. The TT3 features/extended syntax are very compelling. For various reasons people chose not to use CET. Now people can use TT2 and get the features of TT3 (through CET) today.
Hopefully Template::Parser::CET and Template::Alloy can be used in the same spirit as Pugs is used for Perl 6. All of the code from CET and Template::Parser::CET are free for use in TT3.
Download (0.035MB)
Added: 2007-07-04 License: Perl Artistic License Price:
846 downloads
Catalyst::Manual::Tutorial::BasicCRUD 0.02
Catalyst::Manual::Tutorial::BasicCRUD is a Catalyst Tutorial - Part 3: Basic CRUD. more>>
Catalyst::Manual::Tutorial::BasicCRUD is a Catalyst Tutorial - Part 3: Basic CRUD.
Include a Create Action in the Books Controller
Edit lib/MyApp/Controller/Books.pm and enter the following method:
=head2 url_create
Create a book with the supplied title, rating, and author
=cut
sub url_create : Local {
# In addition to self & context, get the title, rating, &
# author_id args from the URL. Note that Catalyst automatically
# puts extra information after the "/ / model(MyAppDB::Book)->create({
title => $title,
rating => $rating
});
# Add a record to the join table for this book, mapping to
# appropriate author
$book->add_to_book_authors({author_id => $author_id});
# Note: Above is a shortcut for this:
# $book->create_related(book_authors, {author_id => $author_id});
# Assign the Book object to the stash for display in the view
$c->stash->{book} = $book;
# This is a hack to disable XSUB processing in Data::Dumper
# (its used in the view). This is a work-around for a bug in
# the interaction of some versions or Perl, Data::Dumper & DBIC.
# You wont need this if you arent using Data::Dumper (or if
# you are running DBIC 0.06001 or greater), but adding it doesnt
# hurt anything either.
$Data::Dumper::Useperl = 1;
# Set the TT template to use
$c->stash->{template} = books/create_done.tt2;
}
Notice that Catalyst takes "extra slash-separated information" from the URL and passes it as arguments in @_. The url_create action then uses a simple call to the DBIC create method to add the requested information to the database (with a separate call to add_to_book_authors to update the join table). As do virtually all controller methods (at least the ones that directly handle user input), it then sets the template that should handle this request.
<<lessInclude a Create Action in the Books Controller
Edit lib/MyApp/Controller/Books.pm and enter the following method:
=head2 url_create
Create a book with the supplied title, rating, and author
=cut
sub url_create : Local {
# In addition to self & context, get the title, rating, &
# author_id args from the URL. Note that Catalyst automatically
# puts extra information after the "/ / model(MyAppDB::Book)->create({
title => $title,
rating => $rating
});
# Add a record to the join table for this book, mapping to
# appropriate author
$book->add_to_book_authors({author_id => $author_id});
# Note: Above is a shortcut for this:
# $book->create_related(book_authors, {author_id => $author_id});
# Assign the Book object to the stash for display in the view
$c->stash->{book} = $book;
# This is a hack to disable XSUB processing in Data::Dumper
# (its used in the view). This is a work-around for a bug in
# the interaction of some versions or Perl, Data::Dumper & DBIC.
# You wont need this if you arent using Data::Dumper (or if
# you are running DBIC 0.06001 or greater), but adding it doesnt
# hurt anything either.
$Data::Dumper::Useperl = 1;
# Set the TT template to use
$c->stash->{template} = books/create_done.tt2;
}
Notice that Catalyst takes "extra slash-separated information" from the URL and passes it as arguments in @_. The url_create action then uses a simple call to the DBIC create method to add the requested information to the database (with a separate call to add_to_book_authors to update the join table). As do virtually all controller methods (at least the ones that directly handle user input), it then sets the template that should handle this request.
Download (0.12MB)
Added: 2006-10-17 License: Perl Artistic License Price:
1108 downloads
ExtUtils::ModuleMaker::TT 0.93
ExtUtils::ModuleMaker::TT is a Perl module that makes skeleton modules with Template Toolkit templates. more>>
ExtUtils::ModuleMaker::TT is a Perl module that makes skeleton modules with Template Toolkit templates.
SYNOPSIS
use ExtUtils::ModuleMaker;
my $mmtt = ExtUtils::ModuleMaker->new (
NAME => My::New::Module,
ALT_BUILD => ExtUtils::ModuleMaker::TT,
TEMPLATE_DIR => ~/.perltemplates,
);
$mmtt->complete_build();
Note: ExtUtils::ModuleMaker has changed substantially in recent releases and ExtUtils::ModuleMaker::TT has similarly changed substantially to be compatible with these changes. Please report any bugs you may find.
This module extends ExtUtils::ModuleMaker to use Template Toolkit 2 (TT2) to build skeleton files for a new module. Templates may either be default templates supplied within the module or user-customized templates in a directory specified with the TEMPLATE_DIR parameter.
Summary of Features/Enhancements:
- Supports building full module skeletons with all the functionality of ExtUtils::ModuleMaker
- Supports adding a single .pm file (and corresponding .t file) to an existing module distribution tree
- Supports creating skeleton text for a single method (generally to be called via a script from within your favorite editor)
- Creates a template directory containing the default templates for subsequent user customization
- Templates can access any parameter in the ExtUtils::ModuleMaker object (e.g. $mmtt, above). This supports transparent, user-extensible template variables for use in custom templates
- Included command-line program makeperlmod provides a command line user interface for module creation. Supports reading default configuration settings from a file and will create a default config file if requested. These config files extend and/or override an ExtUtils::ModuleMaker::Personal::Defaults file. The program can create full distributions, single modules, single methods, default configuration files or default template directories
Notable changes from ExtUtils::ModuleMaker:
- Default templates are generally simpler, as users are expected to customize their own
- .t files for single .pm files created after the original build are named after their corresponding .pm file rather than being sequentially numbered.
- In the command-line program, COMPACT style is set by default
<<lessSYNOPSIS
use ExtUtils::ModuleMaker;
my $mmtt = ExtUtils::ModuleMaker->new (
NAME => My::New::Module,
ALT_BUILD => ExtUtils::ModuleMaker::TT,
TEMPLATE_DIR => ~/.perltemplates,
);
$mmtt->complete_build();
Note: ExtUtils::ModuleMaker has changed substantially in recent releases and ExtUtils::ModuleMaker::TT has similarly changed substantially to be compatible with these changes. Please report any bugs you may find.
This module extends ExtUtils::ModuleMaker to use Template Toolkit 2 (TT2) to build skeleton files for a new module. Templates may either be default templates supplied within the module or user-customized templates in a directory specified with the TEMPLATE_DIR parameter.
Summary of Features/Enhancements:
- Supports building full module skeletons with all the functionality of ExtUtils::ModuleMaker
- Supports adding a single .pm file (and corresponding .t file) to an existing module distribution tree
- Supports creating skeleton text for a single method (generally to be called via a script from within your favorite editor)
- Creates a template directory containing the default templates for subsequent user customization
- Templates can access any parameter in the ExtUtils::ModuleMaker object (e.g. $mmtt, above). This supports transparent, user-extensible template variables for use in custom templates
- Included command-line program makeperlmod provides a command line user interface for module creation. Supports reading default configuration settings from a file and will create a default config file if requested. These config files extend and/or override an ExtUtils::ModuleMaker::Personal::Defaults file. The program can create full distributions, single modules, single methods, default configuration files or default template directories
Notable changes from ExtUtils::ModuleMaker:
- Default templates are generally simpler, as users are expected to customize their own
- .t files for single .pm files created after the original build are named after their corresponding .pm file rather than being sequentially numbered.
- In the command-line program, COMPACT style is set by default
Download (0.025MB)
Added: 2006-10-03 License: Perl Artistic License Price:
1118 downloads
Template::Plugin::Digest::SHA1 0.03
Template::Plugin::Digest::SHA1 is a TT2 interface to the SHA1 Algorithm. more>>
Template::Plugin::Digest::SHA1 is a TT2 interface to the SHA1 Algorithm.
SYNOPSIS
[% USE Digest.SHA1 -%]
[% checksum = content FILTER sha1 -%]
[% checksum = content FILTER sha1_hex -%]
[% checksum = content FILTER sha1_base64 -%]
[% checksum = content.sha1 -%]
[% checksum = content.sha1_hex -%]
[% checksum = content.sha1_base64 -%]
The Digest.SHA1 Template Toolkit plugin provides access to the NIST SHA-1 algorithm via the Digest::SHA1 module. It is used like a plugin but installs filters and vmethods into the current context.
<<lessSYNOPSIS
[% USE Digest.SHA1 -%]
[% checksum = content FILTER sha1 -%]
[% checksum = content FILTER sha1_hex -%]
[% checksum = content FILTER sha1_base64 -%]
[% checksum = content.sha1 -%]
[% checksum = content.sha1_hex -%]
[% checksum = content.sha1_base64 -%]
The Digest.SHA1 Template Toolkit plugin provides access to the NIST SHA-1 algorithm via the Digest::SHA1 module. It is used like a plugin but installs filters and vmethods into the current context.
Download (0.004MB)
Added: 2007-04-04 License: Perl Artistic License Price:
933 downloads
Template::Plugin::Digest::MD5 0.03
Template::Plugin::Digest::MD5 is a TT2 interface to the MD5 Algorithm. more>>
Template::Plugin::Digest::MD5 is a TT2 interface to the MD5 Algorithm.
SYNOPSIS
[% USE Digest.MD5 -%]
[% checksum = content FILTER md5 -%]
[% checksum = content FILTER md5_hex -%]
[% checksum = content FILTER md5_base64 -%]
[% checksum = content.md5 -%]
[% checksum = content.md5_hex -%]
[% checksum = content.md5_base64 -%]
The Digest.MD5 Template Toolkit plugin provides access to the MD5 algorithm via the Digest::MD5 module. It is used like a plugin but installs filters and vmethods into the current context.
When you invoke
[% USE Digest.MD5 %]
the following filters (and vmethods of the same name) are installed into the current context:
md5
Calculate the MD5 digest of the input, and return it in binary form. The returned string will be 16 bytes long.
md5_hex
Same as md5, but will return the digest in hexadecimal form. The length of the returned string will be 32 and it will only contain characters from this set: 0..9 and a..f.
md5_base64
Same as md5, but will return the digest as a base64 encoded string. The length of the returned string will be 22 and it will only contain characters from this set: A..Z, a..z, 0..9, + and /.
Note that the base64 encoded string returned is not padded to be a multiple of 4 bytes long. If you want interoperability with other base64 encoded md5 digests you might want to append the redundant string "==" to the result.
As the filters are also available as vmethods the following are all equivalent:
FILTER md5_hex; content; END;
content FILTER md5_hex;
content.md5_base64;
<<lessSYNOPSIS
[% USE Digest.MD5 -%]
[% checksum = content FILTER md5 -%]
[% checksum = content FILTER md5_hex -%]
[% checksum = content FILTER md5_base64 -%]
[% checksum = content.md5 -%]
[% checksum = content.md5_hex -%]
[% checksum = content.md5_base64 -%]
The Digest.MD5 Template Toolkit plugin provides access to the MD5 algorithm via the Digest::MD5 module. It is used like a plugin but installs filters and vmethods into the current context.
When you invoke
[% USE Digest.MD5 %]
the following filters (and vmethods of the same name) are installed into the current context:
md5
Calculate the MD5 digest of the input, and return it in binary form. The returned string will be 16 bytes long.
md5_hex
Same as md5, but will return the digest in hexadecimal form. The length of the returned string will be 32 and it will only contain characters from this set: 0..9 and a..f.
md5_base64
Same as md5, but will return the digest as a base64 encoded string. The length of the returned string will be 22 and it will only contain characters from this set: A..Z, a..z, 0..9, + and /.
Note that the base64 encoded string returned is not padded to be a multiple of 4 bytes long. If you want interoperability with other base64 encoded md5 digests you might want to append the redundant string "==" to the result.
As the filters are also available as vmethods the following are all equivalent:
FILTER md5_hex; content; END;
content FILTER md5_hex;
content.md5_base64;
Download (0.004MB)
Added: 2007-04-06 License: Perl Artistic License Price:
931 downloads
CGI::Expand 2.02
CGI::Expand is a Perl module that can convert flat hash to nested data using TT2s dot convention. more>>
CGI::Expand is a Perl module that can convert flat hash to nested data using TT2s dot convention.
SYNOPSIS
use CGI::Expand;
use CGI; # or Apache::Request, etc.
$args = expand_cgi( CGI->new(a.0=3&a.2=4&b.c.0=x) );
# $args = { a => [3,undef,4], b => { c => [x] }, }
# Or to catch exceptions:
eval {
$args = expand_cgi( CGI->new(a.0=3&a.2=4&b.c.0=x) );
} or log_and_exit( $@ );
#-----
use CGI::Expand qw(expand_hash);
$args = expand_hash({a.0=>77}); # $args = { a => [ 77 ] }
Converts a CGI query into structured data using a dotted name convention similar to TT2.
expand_cgi works with CGI.pm, Apache::Request or anything with an appropriate "param" method. Or you can use expand_hash directly.
If you prefer to use a different flattening convention then CGI::Expand can be subclassed.
<<lessSYNOPSIS
use CGI::Expand;
use CGI; # or Apache::Request, etc.
$args = expand_cgi( CGI->new(a.0=3&a.2=4&b.c.0=x) );
# $args = { a => [3,undef,4], b => { c => [x] }, }
# Or to catch exceptions:
eval {
$args = expand_cgi( CGI->new(a.0=3&a.2=4&b.c.0=x) );
} or log_and_exit( $@ );
#-----
use CGI::Expand qw(expand_hash);
$args = expand_hash({a.0=>77}); # $args = { a => [ 77 ] }
Converts a CGI query into structured data using a dotted name convention similar to TT2.
expand_cgi works with CGI.pm, Apache::Request or anything with an appropriate "param" method. Or you can use expand_hash directly.
If you prefer to use a different flattening convention then CGI::Expand can be subclassed.
Download (0.008MB)
Added: 2007-07-07 License: Perl Artistic License Price:
840 downloads
Email::Handle 0.01
Email::Handle is a Objective Email Handler. more>>
Email::Handle is a Objective Email Handler.
SYNOPSIS
use Email::Handle;
my $email = Email::Handle->new(root@example.com);
print $email->is_valid ? yes : no;
print $email->obfuscate;
print $email->anonymize;
print $email;
$email->send(From => foo@example.com);
This module is also convenient for using on the DB application with Template and Class::DBI / DBIx::Class.
# setup the table that has column of email with this module
my $loader = Class::DBI::Loader->new(
...
namespace => MyApp
);
$loader->find_class(user)->has_a(email => Email::Handle);
# then output records with TT2
my $tmpl = Template->new;
$tmpl->process(
sample.tt,
{ users => $loader->find_class(user)->retrieve_all }
);
# You can write the template with some methods of this module like this
[% WHILE (user IN users) %]
[% user.email.obfuscate IF user.email.is_valid %]
[% END %]
<<lessSYNOPSIS
use Email::Handle;
my $email = Email::Handle->new(root@example.com);
print $email->is_valid ? yes : no;
print $email->obfuscate;
print $email->anonymize;
print $email;
$email->send(From => foo@example.com);
This module is also convenient for using on the DB application with Template and Class::DBI / DBIx::Class.
# setup the table that has column of email with this module
my $loader = Class::DBI::Loader->new(
...
namespace => MyApp
);
$loader->find_class(user)->has_a(email => Email::Handle);
# then output records with TT2
my $tmpl = Template->new;
$tmpl->process(
sample.tt,
{ users => $loader->find_class(user)->retrieve_all }
);
# You can write the template with some methods of this module like this
[% WHILE (user IN users) %]
[% user.email.obfuscate IF user.email.is_valid %]
[% END %]
Download (0.005MB)
Added: 2007-08-03 License: Perl Artistic License Price:
813 downloads
Secleted [ 0 ] software to compare
- Page: 1 of 1
- 1
Copyright Notice:
Software piracy is theft, Using crack, password, serial numbers, registration codes, key generators is illegal and prevent future software development. The above tt2 search only lists software in full, demo and trial versions for free download. Download links are directly from our mirror sites or publisher sites, torrent files or links from rapidshare.com, yousendit.com or megaupload.com are not allowed