Perl-Sensitive Sunglasses | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Turning a template into Perl code means turning a
template inside out: typical templating systems use
a mixture of HTML and Perl (or Perl and "something
else", which isn't necessarily HTML), where the Perl
is "inside" the HTML. Like this, sort of:
The HTML is the outer layer, and the Perl is contained within special sections marked off by some delimiters. In this case, <% and %>. Most templating systems will turn something like the above into this: Imagine $_out is a subroutine reference that is basically just So essentially, "turning a template into Perl code" has created a piece of Perl code with a bunch of print statements, which is what you might have written if you hadn't used templates at all. This is what I mean by turning the template inside out: you have taken a template that was HTML with embedded Perl, and have turned it into a Perl script with embedded HTML. The advantage to Perl code is that Perl code is fast. :) Ie. if you have a block of Perl code, you can execute it directly; you don't have to parse it as a template. So you can store it in this intermediate Perl script form, and then just run it again without reparsing the original template. This is a relatively standard way of caching templates for many Perl templating engines. And obviously, this is just a small example, but it shows the basics of how it works. In reply to Re: Re: Re: Speed, and my sanity.
by btrott
|
|