Online Games Grumpy Unix Fart Contact Us

DESCRIPTION

This is a simplistic, fast-parsing code-caching template system.

It takes a template, converts it into a perl subroutine and then runs the subroutine as

    $code->($view,$req,\%args); 

Practical upshot is, the CODE is cached, not the data, thereby making it possible to cache templates across multiple requests. On that note, one must be careful not to store data otherwise data will bleed across multiple requests.

Always use my() variables, don't create subroutines, etc..

TEMPLATE SYNTAX

Template syntax is really simple, asp/jsp like:

  <% 
    $req->out()->header("Content-Type: text/plain");
    my $foo = $req->param("FOO");
    my $title = $args->{title};
  %>
  = is a way of placing an implicit $req->out()->print($text), that is,
    it prints the result of the perl expression.
  Hello: FOO is:<%= $foo; %>


    <%-- This is a comment %>

Just comments, perl code and HTML.

TRAPS
  • Run in the GenieMod::View::Template::Environ name space.
  • Everything is run in te GenieMod::View::Template::Environ package name space, under the strict pragma, so, all variables MUST be declared.

  • Don't hold on to data.
  • Templates can (and are) shared among multiple requests, therefore it is usually a mistake to attempt to hold on to any data.

    If you hold on to data, there is the possibility it will bleed across web pages, which is very much not desired if for example, credit card numbers are used.

  • run IN a subroutine.
  • Don't create subs or do anything fancy within a template, as these may create memory leaks.


VARIABLES

Each template has the following variables available:

  • $tmpl
  • The template name.

  • $source
  • The perl source code (what this template looks like after being parsed)

  • $view
  • The View object.

  • $req
  • The request object

  • $args
  • The template arguments, either specified in the conf file in the args section, or, passed along via include()

FUNCTIONS

See GenieMod::View::Template::Environ

METHODS

Internal/Protected methods.

These aren't meant to be used inside templates, but may be useful of extending..

Send to a friend

[add]
Please enter code (Change Code)

Sending Message.