CatalystX::CMS::File - template file class


 use CatalystX::CMS::File;

 # longhand
 my $file = CatalystX::CMS::File->new( $path_to_file );
 $file->fetch if $page->size;
 $file->content('hello world');
 $file->title('super foo');
 $file->commit or die $file->errstr;
 # shorthand
 my $file = CatalystX::CMS::File->new(
                        path    => $path_to_file,
                        title   => 'super foo',
                        content => 'hello world',
 eval { $file->save  } or die $file->errstr;
 print "$file was saved\n";


CatalystX::CMS::File is the object model for the Template Toolkit files that make up the content system of your application. Each object represents a .tt file on the filesystem in a Subversion working directory. An object can be read, written, locked and unlocked on the filesystem. As a subclass of SVN::Class::File, the object can be interrogated for its history, added, deleted, committed or updated.

new( path )

new( path => path [, %param ] )

Create a new object.

Either form of new() may be used, but path is always required.


Reads the file from disk and parses the metadata attributes and content, thereafter accessible via the attrs() and content() methods.

Will croak if path() is false, empty or non-existent.


Returns true if the delegate file has ever been committed to the repository.

write( [ignore_lock] )

Writes attrs() and content() to file location in TT-compatible format.

Will croak on any error.

If the ignore_lock flag is true, write() will ignore any true value of locked(). Otherwise, will croak() if locked() is true.

Returns the size of the resulting file.

create( user )

Acquires lock for user and writes files as a new page.


Calls write().

NOTE: This is not the same as the SVN::Class->update method! If you want that method, use the up() alias instead.

save( message [, leave_lock, username ] )

Will write() file, add() to the SVN workspace if necessary, and then call commit( message ).

Returns -1 if status() of file indicates no modification. Otherwise, returns commit() return value.

Pass a true for leave_lock to leave the lock file intact after the commit().

Pass an authorized username to have the commit() made with that credential.


Returns content() with all TT code wrapped in special XHTML tagset

 <code class="tt">

This is to allow for such code to be escaped online or otherwise parsed with a XML parser.


Peter Karman, <>


Please report any bugs or feature requests to, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


The Minnesota Supercomputing Institute sponsored the development of this software.


Copyright 2008 by the Regents of the University of Minnesota.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.