|
NAMEInline::TT - Provides inline support for template toolkit 2.xABSTRACTInline::TT provides Inline support for Template Toolkit versions 2.x.SYNOPSISuse 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 %] EO_TEMPLATE print hello( { name => 'Rob' } ), "\n"; See the Inline perldoc for even more ways to reference the inline source. 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 (via Inline's caching mechanism).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. Note that leading and trailing spaces are trimmed, further the template toolkit options PRE_CHOMP and POST_CHOMP are set. Currently, there is no way to change these behaviors. OPTIONSYou can pass options to Inline::TT. Two of the options are specific to Inline::TT:
These two options work on the final and complete string. They don't remove ANY interior spaces, only the ones at the beginning and end of the whole string. The rest of the options are passed without comment or validation directly to TT. Note passing options can be done at compile time or at run time. To do it at run time, use Inline->bind. See t/06_options for examples of passing options at run time and at compile time. RATIONALESome people (including me at times) prefer to separate formatting from code, but not by much. For example, we don't like to have xml 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, we can store the templates in the program, but away from the code that supplies their data. Yet, because of the wonders of Inline, we still benefit from disk based caching of templates. (For details about caching see the Inline documentation, search for _Inline.)EXPORTThe names you used for the BLOCKs in the template, are exported into your calling package as sub names.LIMITATIONS and KNOWN BUGSOnly things in BLOCKs are accessible through Inline::TT.SEE ALSOThis module is one of many in the Inline:: family. You must have Inline version 0.42 or higher to use this module. See the Inline documenation for how to control the location of files it caches.AUTHORPhil Crow, <phil@localdomain>COPYRIGHT AND LICENSECopyright (C) 2005 by Phil CrowThis 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.
Visit the GSP FreeBSD Man Page Interface. |