GenieMod::View::Map
ViewMap is used to map view names into their objects.
Constructor, %opt contains:
Conf => Config::General object (with ExtendedAccess)
MapName => Which viewmap to use.
DefaultView => Optional.. View object, when no package is set in the View conf, use this.
Get the Conf object.
Get this viewmap name. Multiple viewmaps can exist side-by-side, each sharing a config file (for global stuff, Ex: DBI settings) but specific viewmap sections are used on a pr. request basis.
Get the default view (GenieMod::View::Template)
Override if you are using the Template Toolkit, HTML Mason or one of the other 9,0000 template kits in use. This won't be called if there is a package/perlfile defined in the viewmap section AND you want to do strange things each time lookup is called.
You can probably just assign it as DefaultView on the constructor, too.
Config::General::Extended is quite flexible, however it can be a real pain to work with when you are using nested configuration sections.
This is a utility method that really ought to be in the Config::General package, alas, it isn't (A good idea might be to extend/wrap Config::General and place it there)
$subconf = $vm->get_conf_path($conf,"viewmap/default/template");
<viewmap default>
<template>
...
</viewmap>
Would fetch above, as a hash ref (or undef)
Lookup a view object.
This package uses the viewmap in Config::General::Extended to locate a particular view for an action, if none found in the action, it will use the global area (the views outside of action sections)
You can use perlfile and package to specifically set the view to use, with the default being GenieMod::View::Template.
<viewmap default>
<view error>
<args>
file = "error.ptml"
</args>
</view>
<action default_index>
<view ok>
<args>
file "index.ptml"
</args>
</view>
<view error>
# package = "GenieMod::View::Template"
# perlfile = "GenieMod/View/Template.pm"
...
</view>
</action>
</viewmap>
# The "plain-text" view.
<viewmap text>
<view error>
<args>
key "value"
</args>
</view>
</viewmap>