Dotiac::DTL::Addon - Manages Dotiac::DTL-addons.


How to write your own addons

Addons are just perl modules living in the Dotiac::DTL::Addon namespace;

They can be called in two ways, as shown here with the example the Dotiac::DTL::Addon::foobar addon.

In a template file:

        {% load foobar %}

In a perl skript:

        use Dotiac::DTL::Addon::foobar; #not require, USE.

When loaded in a template file, the addon stays loaded until the next template calls string(), print() or ... .

When used with "use Dotiac::DTL::Addon::..." the addon is loaded always, this may be sometimes what you disire, but not always:

Take a locale addon for example. One page might need the default english locale and another one will need the german one. If you load the german locale via use ..., it will result in all pages having it.

How it works.

Both {% load x %} and use Dotiac::DTL::Addon::x; call the class-method Dotiac::DTL::Addon::x-import()> when run. This import method makes all the neccessary adjustments to Dotiac::DTL.

When called by {% load x %} the next call to string(),print() or similar will call the Dotiac::DTL::Addon::x-unimport()> method. That method must clean up all the changes done to Dotiac::DTL.

The unload order is the same as the load order, so the addons can just save the values they overwrite (if any).

If you are just adding a tag or a filter, you can just provide empty import() and unimport() methods, but see the warning below.

Example for a locale addon

This adds a german loacle as "german_locale":

        package Dotiac::DTL::Addon::german_locale;
        require Dotiac::DTL::Filter;
        use strict;
        use warnings;
        #Save the old values
        our @datemonths;
        our @datemonthl;
        our @datemontha;
        our @weekdays;
        our @weekdayl;
        our @timeampm;
        our @timespotnames;
        our @datesuffixes;
        our @filesizeformat;
        our $pluralizedefault;
        our $floatformatlocale;
        our @timenames;
        our $TIME_FORMAT;
        our $DATE_FORMAT;
        our $DATETIME_FORMAT;

        sub import {
                #Save values
                #Set new values
                @Dotiac::DTL::Filter::datemonths=qw( Jan Feb M&aum;r Apr Mai Jun Jul Aug Sep Okt Nov Dez );
                @Dotiac::DTL::Filter::datemonthl=qw( Januar Februar März April Mai Juni Juli August September Oktober November Dezember );
                @Dotiac::DTL::Filter::datemontha=qw( Jan. Feb. März April Mai Juni Juli Aug. Sep. Okt. Nov. Dez. );
                @Dotiac::DTL::Filter::weekdays=qw/So Mo Di Mi Do Fr Sa/;
                @Dotiac::DTL::Filter::weekdayl=qw/Sonntag Montag Dienstag Mittwock Donnerstag Freitag Samstag/;
                @Dotiac::DTL::Filter::timeampm=qw/a.m. p.m. AM PM/;
                @Dotiac::DTL::Filter::timespotnames=qw/Mitternacht Mittag/;
                @Dotiac::DTL::Filter::filesizeformat=qw/Bytes Kb Mb Gb Tb Eb Pb vielebytes vielebytes vielebytes vielebytes/;
                $Dotiac::DTL::Filter::floatformatlocale=sub {my $v=shift;$v=~s/\./,/g;return $v;};
                @Dotiac::DTL::Filter::timenames=qw/Jahr Jahren Monat Monaten Woche Wochen Tag Tagen Stunde Stunden Minute Minuten/;
                #Time format
                $Dotiac::DTL::DATE_FORMAT="d. M. Y";
                $Dotiac::DTL::DATETIME_FORMAT="d. M. Y, H:i";
        sub unimport {
                #Restore values

Example for a filter addon

        package Dotiac::DTL::Addon::myfilters;
        sub import {
                #No need to do anything here, filters can stay loaded all the time, but see the warning below.
        sub unimport {
        package Dotiac::DTL::Filters;
        #Not very useful filters, they should just serve as an example:
        # don't forget: Filters get and return Dotiac::DTL::Value objects.
        sub foobar {
                return Dotiac::DTL::Value->safe("Foobar")
        sub helloworld {
                return Dotiac::DTL::Value->safe("Hello, World")


Using the above way to write a filter addon, will result in undefined behavior when two filters share the same name. This is because unimport() does nothing. A better way would be: Let import overwrite the function via modifying the symbol table and let unimport reverse it again.

Any tag addon

Tags can't share the same name, because they would be in the same file. (Unless you make it the wrong file, but that's not my problem then)

        package Dotiac::DTL::Addon::mytagcollection;
        require Dotiac::DTL::Tag::mytag1;
        require Dotiac::DTL::Tag::mytag2;
        sub import {
        sub unimport {

Internal stuff of Dotiac::DTL::Addons

These should not be used from anybody else than Dotiac::DTL::Core.


Calls unimport on all methodes loaded by {% load %}


Stores the loaded module names;


Modules that shouldn't be included into compiled template (by {% load %}) should register themselves here.

These are mostly:

Parser changing modules.

The Parser is not needed in compiled templates

Tag adding modules.

Since the Tags are compiled down to Perl-code, their source is not needed anymore

Modules that add filters have to stay


If you find a bug, please report it.



Dotiac::DTL was built according to


Marc-Sebastian Lucksch