Catalyst::Helper::TDClass - Helper for creating TD Template classes


Catalyst-View-TD documentation Contained in the Catalyst-View-TD distribution.

Index


Code Index:

Name

Top

Catalyst::Helper::TDClass - Helper for creating TD Template classes

Synopsis

Top

    ./script/myapp_create.pl TDClass HTML

Description

Top

Helper for creating TD Template classes.

Methods

mk_comptest

Creates a test script for the view class.

mk_stuff

Creates a template class.

SEE ALSO

Top

Catalyst::View::TD, Catalyst::Helper::View::TD

Author

Top

David E. Wheeler <david@justatheory.com>

License

Top

This library is free software. You can redistribute it and/or modify it under the same terms as perl itself.


Catalyst-View-TD documentation Contained in the Catalyst-View-TD distribution.
package Catalyst::Helper::TDClass;

use strict;
use warnings;

our $VERSION = '0.12';

sub mk_stuff {
    my ( $self, $helper, $name ) = @_;

    $name ||= $helper->{name};
    my $class = "$helper->{app}::Templates::$name";

    my @path = split /::/, $class;
    my $file = pop @path;
    my $path = File::Spec->catdir( $helper->{base}, 'lib', @path );
    $helper->mk_dir($path);
    $file = File::Spec->catfile( $path, "$file.pm" );
    local $helper->{file} = $file;
    $helper->render_file('tmpl_class', $file, {
        class    => $class,
        name     => $name,
        scaffold => $name !~ /::/,
    });
}

1;

__DATA__

__tmpl_class__
package [% class %];

use strict;
use warnings;
use parent 'Template::Declare::Catalyst';
use Template::Declare::Tags;
[% IF scaffold -%]

# See Template::Declare docs for details on creating templates, which look
# something like this.
# template hello => sub {
#     my ($self, $vars) = @_;
#     html {
#         head { title { "Hello, $vars->{user}" } };
#         body { h1    { "Hello, $vars->{user}" } };
#     };
# };
[% END -%]

1;

__the_end__