Marc - Sebastian Lucksch > Dotiac-0.8 > Dotiac::DTL::Reduced

Download:
dotiac/Dotiac-0.8.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 0.8   Source   Latest Release: Dotiac-0.8_1

NAME ^

Dotiac::DTL::Reduced - Dotiac::DTL without the parser.

SYNOPSIS ^

        require Dotiac::DTL::Reduced;
        $t=Dotiac::DTL->new("compiled.html") #Works only with compiled templates
        $t->print();

DESCRIPTION ^

Dotiac::DTL::Reduced is a version of Dotiac::DTL that contains everything needed to run compiled templates. The other stuff, i.e. parser and Tags are not loaded, so it should save some memory.

I recon it makes almost no difference at all with mod_perl or FastCGI, but having all the tag modules parsed for nothing will impact normal CGI performance.

See Dotiac::DTL::Compiled for pros and cons of compiled templates.

Note This will only run compiled templates, if your compiled template includes a normal template, it will die.

It will also create a warning when the template is outdated and needs to be recompiled.

Compiling templates

Since Dotiac::DTL::Reduced will only work with compiled templates, you can use this litte script to compile all templates in the current folder:

        require Dotiac::DTL; #Not Reduced here, we need the parser for this.
        Dotiac::DTL->newandcompile($_) foreach (<*.html>); #You might have to change this to whatever file extension you are using.

But see Dotiac::DTL::Compiled before you do this to read up on compiled template pros and cons.

You will also have to recompile everytime you change something. The above script will only compile the changed files in that case.

Changes from the normal Dotiac::DTL

Everything discriped in Dotiac::DTL and Dotiac::DTL::Core still applies here except:

new(FILENAME)

Creates a template from a compiled version or loads it from the cache.

FILENAME

The filename of the compiled template to open. If you give it a scalarref it will die.

        require Dotiac::DTL::Reduced;
        $t=Dotiac::DTL->new("file.html"); #Will load "file.html.pm" or die.
COMPILE

The COMPILE parameter from Dotiac::DTL->new() is ignored. It wouldn't work anyway

Returns a Dotiac::DTL::Template object.

And what about my own compiled templates?

This works like it should: (See Dotiac::DTL::Compiled)

        package MyTemplate;
        sub print {
                my ($vars,$escape)=(shift(),shift());
                print "There are ".keys(%$vars)." parameters registered and x is $vars->{x}\n";
        }
        sub string {
                my ($vars,$escape)=(shift(),shift());
                return "There are ".keys(%$vars)." parameters registered and x is $vars->{x}\n";
        }
        sub eval {
                #nothing for now.
        }
        package main;
        require Dotiac::DTL;
        my $mytemplate=Dotiac::DTL->compiled("MyTemplate");

Template(FILE)

Creates a template from FILE. This function is for Django like syntax, use new(FILE) for better results and control.

FILE

This can be a filename or a string containing the template data.

Template() will search the current directory and @Dotiac::DTL::TEMPLATE_DIRS (See Core.pm) for either FILE, FILE.html or FILE.txt and open the first file found.

If no file is found it treats FILE as template data and will parse the string.

Context(HASHREF)

Python's Django uses Context() to create a Context, Dotiac::DTL doesn't use this, it just uses a hash.

HASHREF

A Hash of parameters.

Returns the first Argument.

BUGS ^

If you find a bug, please report it.

SEE ALSO ^

http://www.djangoproject.com, Dotiac::DTL

LEGAL ^

Dotiac::DTL was built according to http://docs.djangoproject.com/en/dev/ref/templates/builtins/.

AUTHOR ^

Marc-Sebastian Lucksch

perl@marc-s.de

syntax highlighting: