Template::Manual::Internals

Template::Manual::Internals is a template toolkit internals.
Download

Template::Manual::Internals Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Andy Wardley
  • Publisher web site:
  • http://search.cpan.org/~abw/

Template::Manual::Internals Tags


Template::Manual::Internals Description

Template::Manual::Internals is a template toolkit internals. Template::Manual::Internals is a template toolkit internals.The Template module is simply a front end module which creates and uses a Template::Service and pipes the output wherever you want it to go (STDOUT by default, or maybe a file, scalar, etc). The Apache::Template module (available separately from CPAN) is another front end. That creates a Template::Service::Apache object, calls on it as required and sends the output back to the relevant Apache::Request object.These front-end modules are really only there to handle any specifics of the environment in which they're being used. The Apache::Template front end, for example, handles Apache::Request specifics and configuration via the httpd.conf. The regular Template front-end deals with STDOUT, variable refs, etc. Otherwise it is Template::Service (or subclass) which does all the work.The Template::Service module provides a high-quality template delivery service, with bells, whistles, signed up service level agreement and a 30-day no quibble money back guarantee. "Have a good time, all the time", that's our motto.Within the lower levels of the Template Toolkit, there are lots of messy details that we generally don't want to have to worry about most of the time. Things like templates not being found, or failing to parse correctly, uncaught exceptions being thrown, missing plugin modules or dependencies, and so on. Template::Service hides that all away and makes everything look simple to the outsider. It provides extra features, like PRE_PROCESS, PROCESS and POST_PROCESS, and also provides the error recovery mechanism via ERROR. You ask it to process a template and it takes care of everything for you. The Template::Service::Apache module goes a little bit further, adding some extra headers to the Apache::Request, setting a few extra template variables, and so on.For the most part, the job of a service is really just one of scheduling and dispatching. It receives a request in the form of a call to its process() method and schedules the named template specified as an argument, and possibly several other templates (PRE_PROCESS, etc) to be processed in order. It doesn't actually process the templates itself, but instead makes a process() call against a Template::Context object.Template::Context is the runtime engine for the Template Toolkit - the module that hangs everything together in the lower levels of the Template Toolkit and that one that does most of the real work, albeit by crafty delegation to various other friendly helper modules.Given a template name (or perhaps a reference to a scalar or file handle) the context process() method must load and compile, or fetch a cached copy of a previously compiled template, corresponding to that name. It does this by calling on a list of one or more Template::Provider objects (the LOAD_TEMPLATES posse) who themselves might get involved with a Template::Parser to help turn source templates into executable Perl code (but more on that later). Thankfully, all of this complexity is hidden away behind a simple template() method. You call it passing a template name as an argument, and it returns a compiled template in the form of a Template::Document object, or otherwise raises an exception.A Template::Document is a thin object wrapper around a compiled template subroutine. The object implements a process() method which performs a little bit of housekeeping and then calls the template subroutine. The object also defines template metadata (defined in directives) and has a block() method which returns a hash of any additional definitions found in the template source.So the context fetches a compiled document via its own template() method and then gets ready to process it. It first updates the stash (the place where template variables get defined - more on that shortly) to set any template variable definitions specified as the second argument by reference to hash array. Then, it calls the document process() method, passing a reference to itself, the context object, as an argument. In doing this, it provides itself as an object against which template code can make callbacks to access runtime resources and Template Toolkit functionality.What we're trying to say here is this: not only does the Template::Context object receive calls from the outside, i.e. those originating in user code calling the process() method on a Template object, but it also receives calls from the inside, i.e. those originating in template directives of the form .Before we move on to that, here's a simple structure diagram showing the outer layers of the Template Toolkit heading inwards, with pseudo code annotations showing a typical invocation sequence. Requirements: · Perl


Template::Manual::Internals Related Software