Online Games Grumpy Unix Fart Contact Us

Custom packages (Or, how NOT to use View::Template)

As alluded to earlier, you are not required to use a View::Template object, you can use whatever package you want. Customized to suit your needs, a prime example (and one that I've used in the past) is a wrapper around some of the graphics modules found on CPAN.

Consider this example

    <view error>
        package = "GenieMod::View::Template"
        perlfile = "GenieMod/View/Template.pm"
        <args>
            file = "error.ptml"
        </args>
    </view>


You will notice optional package and perlfile keys. These specify that for this particular view, you would like to use a custom perl package (one that implements the view interface) and that this particular implementation is located in the file pointed to by perlfile (in our case its GenieMod/View/Template.pm

All you need to do is set package and perlfile to your custom setup for this particular view. Since the Controller pays no attention to the underlying views, it can be a drop in replacement for templates.

It should be noted that in FastCGI environments, you'll want to preload these packages, while in CGI mode, delay is always faster. (see the persistent method of GenieMod::Controller for a way to do this. You'll need to set: Persist => 1 for it to work)

Send to a friend

[add]
Please enter code (Change Code)

Sending Message.