<<O>>  Difference Topic LinuxBookReviewsPerlTemplateToolkit (r1.2 - 05 May 2006 - LeeMcKusick)
Added:
>
>

Perl Template Toolkit


Deleted:
<
<
Book review of Perl Template Toolkit

by Darrren Chamberlain, David Cross, and Andy Wardley. O'Reilly, c. 2004
Changed:
<
<
Reviewed by Lee McKusick
>
>
Reviewed by -- LeeMcKusick - 04 May 2006

Added:
>
>
Perl Template Toolkit is a guide to a mini-language dedicated to plugging data into a framework. The obvious main use of the Template Toolkit is generating web pages from a database.

Changed:
<
<
Perl Template Toolkit is a guide to a mini-language dedicated to plugging data into a framework. The obvious main use of the Template Toolkit is generating web pages from a database. Beyond being a page generator, this toolkit can fill any kind of template destined for any file format. The book examples show plain text, PDF and XML and html. The grammar for describing the templates is essentially "any text with tags embedded". Where the Toolkit shines is it provides the text handling power of Perl with a simple and clear way to fill a template with data. This language can fill a template knowing the first item of data, the last item of data and sorting the data, while the template is being filled.
>
>
Beyond being a page generator, this toolkit can fill any kind of template destined for any file format. The book examples show plain text, PDF and XML and html. The grammar for describing the templates is essentially "any text with tags embedded".

Changed:
<
<
The main reader of this book is a Perl programmer. A key skill you need to read and use this book unassisted is to understand what a Perl object is and how to trace out the data you can feed the object and how to get the data back from the object after it did whatever to your input data.
>
>
The Template::Toolkit goes beyond first generation substitution type template scripts. Template::Toolkit provides the text handling power of Perl with a simple and clear way to fill a template with data. This language can fill a template in a sophisticated "look ahead" manner. Templates can accommodate the first item of data, the last item of data, and missing data. Templates can sort data, count data, and filter the data at the time the template is being filled. And the scripting and syntax of these actions is easy to read.

This book is written for a Perl programmer. A key skill you need to read and use this book unassisted is to understand what a Perl object is, how to trace out the data you can feed the object and how to get the data back from the object after it did whatever to your input data.


The strong point of the book is it is a classic definitive guide in the O'Reilly format.

Line: 19 to 23

You need to understand object syntax for Perl. Fragments of code typically appear like this:

Added:
>
>


use Template; my $tt = Template->new();
Added:
>
>

Having at hand a copy of "Learning Perl" from O'Reilly is not enough introduction specifically to objects to adequately understand Perl Template Toolkit after the introductory chapters.


You need to provide you own solution to creating the unique filenames for the leaves of your finished filled out data tree. Perl Template Toolkit (the book) does not provide explicit samples showing creation of pages from data alone.

Line: 28 to 36

Here are some workarounds for accessing this powerful language.

Changed:
<
<
First I point the reader to the following March 2006 Linux Magazine article:
>
>
  • First I point the reader to the following March 2006 Linux Magazine article:

"Building a Static Site with Template Toolkit" by Randal Schwartz, orignally published in Linux Magazine March 2006 issue. On the internet at: http://www.linux-mag.com/content/view/2536/

Line: 38 to 46

The Randall Schwartz article cuts the work area setup to three subdirectories underneath a "projectname" directory. You need projectname/src/ projectname/dest/ and projectname/lib/.

Changed:
<
<
Second, the Perl Template Toolkit depends on setting up a working environment. This assumes you start a "terminal shell" and change directory to projectname created above. Here are two Unix and Linux environment changes. The shorthand "~/" means these files are in your /home/username/ directory on Linux.
>
>
  • Second, the Perl Temp`late Toolkit depends on setting up a working environment.

Changed:
<
<
Part of template toolkit depends on finding a specific ttree configuration file. To bypass all the hoodle of making ttree work right every time, set an environment variable:
>
>
Part of template toolkit depends on finding a specific ttree configuration file. To bypass all the hoodle of making ttree work right every time, set an environment variable. And then, for ease of using the vi editor, alter it's startup file to provide automatic indentation and syntax highlighting.

Added:
>
>


# Edit ~/.bashrc where ttreerc is a file location on your system export TTREERC='/home/lmckusic/silentauction/ttreerc'

" Edit ~/.vimrc to turn on these useful editing features if you use vi set autoindent " always set autoindenting on syntax on

Added:
>
>

Changed:
<
<
Third
Packages for the Template Toolkit. The Debian packages below worked for me:
>
>
  • Third: Linux packages for the Template Toolkit.

The Debian packages below worked for me:


Debian packages are: libtemplate-perl, libtemplate-perl-doc, libgd-perl, libgd-text-perl, libgd-graph-perl

 <<O>>  Difference Topic LinuxBookReviewsPerlTemplateToolkit (r1.1 - 04 May 2006 - LeeMcKusick)
Line: 1 to 1
Added:
>
>

Book review of Perl Template Toolkit by Darrren Chamberlain, David Cross, and Andy Wardley. O'Reilly, c. 2004

Reviewed by Lee McKusick

Perl Template Toolkit is a guide to a mini-language dedicated to plugging data into a framework. The obvious main use of the Template Toolkit is generating web pages from a database. Beyond being a page generator, this toolkit can fill any kind of template destined for any file format. The book examples show plain text, PDF and XML and html. The grammar for describing the templates is essentially "any text with tags embedded". Where the Toolkit shines is it provides the text handling power of Perl with a simple and clear way to fill a template with data. This language can fill a template knowing the first item of data, the last item of data and sorting the data, while the template is being filled.

The main reader of this book is a Perl programmer. A key skill you need to read and use this book unassisted is to understand what a Perl object is and how to trace out the data you can feed the object and how to get the data back from the object after it did whatever to your input data.

The strong point of the book is it is a classic definitive guide in the O'Reilly format.

The careful and intense focus on the "Template Toolkit language" is also the weakness of the book. The reviewer does not have the programming knowledge this book expects. Like a number of other definitive guide type books, Perl Template Toolkit stops at the inner edge of the subject.

Here are the specific implementation roadblocks I encountered in trying to deliver a 12 page project using the Perl Template Toolkit:

You need to understand object syntax for Perl. Fragments of code typically appear like this:

use Template; my $tt = Template->new();

You need to provide you own solution to creating the unique filenames for the leaves of your finished filled out data tree. Perl Template Toolkit (the book) does not provide explicit samples showing creation of pages from data alone.

To the template toolkit mailing list, I posted a crude perl script to do this: "Generating stub files in src using the PERL filter", April 5, 2006 posted to templates@template-toolkit.org

Here are some workarounds for accessing this powerful language.

First I point the reader to the following March 2006 Linux Magazine article:

"Building a Static Site with Template Toolkit" by Randal Schwartz, orignally published in Linux Magazine March 2006 issue. On the internet at: http://www.linux-mag.com/content/view/2536/

Randal Schwartz's article is a runnable example of the Template Toolkit. The article reflects three years of consulting experience of putting up Template Toolkit installations for many clients.

This is the article that initially got me started using the Template Toolkit for an urgent project that should have been finished last month.

The Randall Schwartz article cuts the work area setup to three subdirectories underneath a "projectname" directory. You need projectname/src/ projectname/dest/ and projectname/lib/.

Second, the Perl Template Toolkit depends on setting up a working environment. This assumes you start a "terminal shell" and change directory to projectname created above. Here are two Unix and Linux environment changes. The shorthand "~/" means these files are in your /home/username/ directory on Linux.

Part of template toolkit depends on finding a specific ttree configuration file. To bypass all the hoodle of making ttree work right every time, set an environment variable:

# Edit ~/.bashrc where ttreerc is a file location on your system export TTREERC='/home/lmckusic/silentauction/ttreerc'

" Edit ~/.vimrc to turn on these useful editing features if you use vi set autoindent " always set autoindenting on syntax on

Third
Packages for the Template Toolkit. The Debian packages below worked for me:

Debian packages are: libtemplate-perl, libtemplate-perl-doc, libgd-perl, libgd-text-perl, libgd-graph-perl

A Red Hat fedora RPM package according to Google is : perl-Template-Toolkit-2.14-1.0-*.rpm

-- LeeMcKusick - 04 May 2006

Revision r1.1 - 04 May 2006 - 22:08 - LeeMcKusick
Revision r1.2 - 05 May 2006 - 04:13 - LeeMcKusick