HTML::Template::Compiled

Template System Compiles HTML::Template files to Perl code
Download

HTML::Template::Compiled Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Tina Müller
  • Publisher web site:
  • http://search.cpan.org/~tinita/

HTML::Template::Compiled Tags


HTML::Template::Compiled Description

Template System Compiles HTML::Template files to Perl code HTML::Template::Compiled is a template system which uses the same template syntax as HTML::Template and the same Perl API (see "COMPATIBILITY" for what you need to know if you want (almost) the same behaviour). Internally it works different, because it turns the template into perl code, and once that is done, generating the output is much faster than with HTML::Template (3-7 times at the moment, depending on the options you use (see "BENCHMARKS" for some examples), when both are run with loop_context_vars 0. It also can generate perl files so that the next time the template is loaded it doesn't have to be parsed again. The best performance gain is probably reached in applications running under mod_perl, for example.If you don't use any caching HTC will be very slow, slower than TT. Also with file caching but without memory caching it's the slowest templating module I know. With memory caching, though, it is one of the fastest, even faster sometimes (depending on options and template size) than C modules.You might want to use HTML::Template::Compiled::Lazy for CGI environments as it doesn't parse the template before calling output. But note that HTC::Lazy isn't much tested, and I don't use it myself, so there's a lack of experience. If you use it and have problems, please report.HTC will use a lot of memory because it keeps all template objects in memory. If you are on mod_perl, and have a lot of templates, you should preload them at server startup to be sure that it is in shared memory. At the moment HTC is not fully tested for keeping all data in shared memory (e.g. when a copy-on-write occurs), but it seems like it's behaving well. For preloading you can now use HTML::Template::Compiled->preload($dir).Generating code, writing it on disk and later eval() it can open security holes, for example if you have more users on the same machine that can access the same files (usually an http server running as 'www' or 'nobody'). See "SECURITY" for details what you can do to safe yourself.NOTE: If you don't need any of the additional features listed below and if you don't need the speed (in many cases it's probably not worth trading speed for memory), then you might be better off with just using HTML::Template.NOTE2: If you have any questions, bug reports, send them to me and not to Sam Tregar. This module is developed by me at the moment, independently from HTML::Template, although I try to get most of the tests from it passing for HTC. See "RESOURCES" for current information.SYNOPSIS use HTML::Template::Compiled speed => 1; # or for compatibility with HTML::Template # use HTML::Template::Compiled compatible => 1; # or use HTML::Template::Compiled::Classic my $htc = HTML::Template::Compiled->new(filename => 'test.tmpl'); $htc->param( BAND => $name, ALBUMS => , ); print $htc->output; test.tmpl: Band: < TMPL_VAR BAND > < TMPL_LOOP ALBUMS > Title: < TMPL_VAR TITLE > (< TMPL_VAR YEAR >) < /TMPL_LOOP > Requirements: · Perl


HTML::Template::Compiled Related Software