Krang::Template - Interface for managing template objects


 # create a new template
 my $template = pkg('Template')->new(category    => $category,
                                     content     => '<tmpl_var test>',
                                     filename    => 'test.tmpl');
 # save contents of the object to the DB.
 # put the object back into circulation for other users
 # checkout object to work on it
 # saves to the db again, increments version field of the object
 # use this template for testing, will override deployed versions of the
 # same template
 # no longer use this template for testing
 # Mark the template as having been deployed to the Krang publish path.
 # unsets testing flag in the database
 # Mark the template as not existing in the publish path.
 # unsets deployed, deploy_version, deploy_date.
 # reverts to template revision specified by $version
 $template->revert( $version );
 # deploy template
 # remove all references to the object in the template and
 # template_version tables
 # returns array of template objects matching criteria in %params
 my @templates = pkg('Template')->find( %params );
 # Get permissions for this object
 $template->may_see() || croak("Not allowed to see");
 $template->may_edit() || croak("Not allowed to edit");


Templates determine the form of this system's output. This module provides a means to check in, check out, edit, revert, save, and search Template objects.

A template is either associated with an element class and hence determines its formatting or it may serve as some manner of miscellaneous utility whether formatting or otherwise. Template data, i.e. the 'content' field, is, at present, intended to be in HTML::Template format. All template filenames will end in the extension '.tmpl'. Users have the ability to revert to any previous version of a template.

This module interfaces or will interface with Krang::CGI::Template, Krang::Burner, the FTP interface, and the SOAP interface.



This module employs Krang::MethodMaker to provide accessors for all and mutators for some of the object's fields. The fields can be accessed and set in the following manner:

 # accessor
 $value = $template_obj->readable_field();
 # mutator
 $template->obj->readable_and_writeable_field( $value );

The four read/write fields for the object are:

The remaining read-only fields are:



 * Prevent duplicate template objects and paths once pkg('Category') is


Krang, Krang::DB, Krang::Log