Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

4. Template Directives > Perl Blocks

Perl Blocks

The Template Toolkit directives that we have seen up to now together define a presentation language that allows you to do just about anything you need to in order to control the display of your data. This is in keeping with the Template Toolkit philosophy of separating processing from presentation.

However, there may be times when you want to go beyond what Template Toolkit offers you. Very occasionally you might need the power of a full programming language within your templates. When nothing else will do, the Template Toolkit also gives you the option of embedding Perl directly in your templates in PERL and RAWPERL directive blocks.

Using PERL and RAWPERL blocks isn’t something that is widely encouraged because it tends to make templates messy and hard to read. It also leads to a poor separation of concerns when you mix application code with presentation templates. However, the Template Toolkit doesn’t enforce this separation, so you can embed Perl code inside your templates if you really want to. Because we don’t encourage it, this feature is disabled by default. You will have to enable the EVAL_PERL configuration option to embed Perl code.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint