| Catalyst-View-TD documentation | Contained in the Catalyst-View-TD distribution. |
Catalyst::Helper::TDClass - Helper for creating TD Template classes
./script/myapp_create.pl TDClass HTML
Helper for creating TD Template classes.
Creates a test script for the view class.
Creates a template class.
David E. Wheeler <david@justatheory.com>
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__