NAME

AmphetaDesk::Templates - Encapsulates the templating engine of AmphetaDesk

SYNOPSIS

    # include another template.
    [$ include( $file_path ) $]

    # send data to the browser. two different ways.
    $OUT .= "this is sent to the browser immediately.

    # this is delayed until send_to_browser is called.
    to_browser("random crap for the ", $browser",  "whoooO");
    to_browser("the above was an array. this is a string."); 
    $OUT = send_to_browser;

DESCRIPTION

This package encapsulates all the various template handling code. It uses Text::Template to parse the templates, and then sends the results back to the calling function for further action. Simple stuff. More user-level information about this template can be found in the "Skinning" doc. All URLs accessed through the AmphetaDesk webserver (save for images) are parsed for templating code. This allows you to make new templates up as you go, and have them immediately available for use through the webserver.

METHODS

include($file_path)
Only used within the user templates, this routine parses another template and puts the results in the current template. It's meant reproduce (to a small degree) server-side includes. The code for this routine comes almost verbatim from the Text::Template documentation. If the parse is successful, it'll return the results of the template, else undef.
to_browser and send_to_browser
In previous versions of the AmphetaDesk template code, we concat'd all of our strings together in the templates. This started causing memory leaks and slowdowns, due to the sheer amount of concat's we do for heavy users. Now we throw everything into an array (via to_browser), and only concat things together when we're done everything else via send_to_browser). You can, of course, choose not to use these routines when it's not needed, such as small templates. If that's the case, you can send straight to Text::Template's $OUT. An example of usage:
    $OUT .= "this is sent to the browser immediately.

    # this is delayed until send_to_browser is called.
    to_browser("random crap for the ", $browser",  "whoooO");
    to_browser("the above was an array. this is a string."); 
    $OUT = send_to_browser;
to_browser always returns 1, and send_to_browser returns a giant string of all the data that has previously been set with to_browser - it'll delete the internally saved data upon output. More information about these routines can be found in the "Skinning" docs.

SEE ALSO

AUTHOR

Morbus Iff, <morbus@disobey.com>

COPYRIGHT AND LICENSE

Copyright 2000-2004 Morbus Iff <morbus@disobey.com>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.