NAME

Inline::TT - Provides inline support for template toolkit 2.x

ABSTRACT

Inline::TT provides Inline support for Template Toolkit versions 2.x.

SYNOPSIS

  use Inline TT => 'DATA';

  print hello( { name => 'Rob' } ), "\n";

  print goodbye( { name => 'Rob' } ), "\n";

  __DATA__
  __TT__
  [% BLOCK hello %]
	<H1> Hello [% name %], how are you? </H1>
  [% END %]
  [% BLOCK goodbye %]
    <H1> Goodbye [% name %], have a nice day. </H1>
  [% END %]

Alternatively:

  use Inline TT => << EO_TEMPLATE
  [% BLOCK hello %]
	<H1> Hello [% name %], how are you? </H1>
  [% END %]
  [% BLOCK goodbye %]
    <H1> Goodbye [% name %], have a nice day. </H1>
  [% END %]
  EO_TEMPLATE

  print hello( { name => 'Rob' } ), "\n";

  print goodbye( { name => 'Rob' } ), "\n";

See the Inline perldoc for even more choices.

DESCRIPTION

Inline::TT provides Inline access to version 2.0 and higher of the Template Toolkit. This allows you to house your templates inside the source code file, while retaining the ability to cache compiled templates on the disk.

The names of the blocks in the template are exported as functions. Call these with a reference to a hash of values, which will be used for interpolation in the templates. This hash reference is the same as the second argument to the process method of any Template object. The output from template toolkit will be returned to you as a single string.

RATIONALE

Some people (including me at times) prefer to separate formatting from code, but not by much. We don't like to have html embedded inside Perl, but we don't want to have to hunt on the disk for a template whose name is likely hidden in a config file (a config file whose name we may not even remember). By using Inline::TT, you can store the templates in the program, but away from the code that supplies their data. Yet, because of the wonders of Inline, you still have caching of templates. (For details about caching see the Inline documentation, search for _Inline.)

EXPORT

The names you used for the blocks in the template, are exported into your calling package as sub names.

LIMITATIONS and KNOWN BUGS

Only things in BLOCKs are accessible through Inline::TT.

SEE ALSO

This module is one of many in the Inline:: family. You must have Inline version 0.44 or higher to use this module. See the Inline documenation for how to control the location of files it caches.

AUTHOR

Phil Crow, <phil@localdomain>

COPYRIGHT AND LICENSE

Copyright (C) 2005 by Phil Crow

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available.