| Catalyst-View-Seamstress documentation | Contained in the Catalyst-View-Seamstress distribution. |
Catalyst::Helper::View::Seamstress - Helper for Seamstress Views
script/create.pl view Seamstress Seamstress [ comp_root skeleton ]
Helper module for
Catalyst::View::Seamstress.
It will create 3 (three) configuration variables in
MyApp::View::Seamstress:
comp_root is the directory above the directory where the HTML files
that Seamstress will process are. This directory is usually a sister
directory to root, scripts, and so forth.
If you don't set this, the helper script will create code that will come up with a sensible default for this directory.
A skeleton is a Seamstress-style Perl class as discussed in "The_meat-skeleton_paradigm" in HTML::Seamstress.
meat_pack is a subroutine which will pack meat into the skeleton.
It is also discussed along with the skeleton at the above link.
Note that although the helper will create 3 configuration variables,
only 2 can be set from the command line. The default meat_pack
routine cannot be over-ridden from the command line helper script because
no sensible substitute routine could be handled well in one-line.
Catalyst::View::Seamstress, Catalyst::Manual, Catalyst::Test, Catalyst::Request, Catalyst::Response, Catalyst::Helper,
Terrence Brannon <metaperl@gmail.com>
This library is free software . You can redistribute it and/or modify it under the same terms as perl itself.
[% class %] - Catalyst Seamstress View
See [% app %]
Catalyst Seamstress View.
This method returns the root of your html file tree which is normally something like /full/path/to/MyApp/root/
[% author %]
This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
| Catalyst-View-Seamstress documentation | Contained in the Catalyst-View-Seamstress distribution. |
package Catalyst::Helper::View::Seamstress; use strict;
sub default_comp_root { use File::Spec; File::Spec->rel2abs('root'); } sub comp_root_logic { q/do { my ($appname) = split '::', __PACKAGE__; $appname->config->{root} } / } sub mk_compclass { my ( $self, $helper, $comp_root, $skeleton ) = @_; my $file = $helper->{file}; unless ($comp_root) { $comp_root = comp_root_logic; print STDERR '$comp_root not supplied... defaulting to ' . $comp_root; } $helper->render_file( 'compclass', $file, { comp_root => $comp_root, skeleton => $skeleton, } ); }
1; __DATA__ __compclass__ package [% class %]; use strict; #use base 'Catalyst::Base'; #use base 'Catalyst::View::Seamstress'; #use base qw(Class::Prototyped HTML::Seamstress); use base qw(Catalyst::View::Seamstress HTML::Seamstress); use vars qw($comp_root); BEGIN { # edit this to '/ernest/dev/catalyst-simpleapp/root' # or something along those lines... wherever the # HTML for Seamstress to rewrite is. $comp_root = [% comp_root %]; $comp_root .= '/' unless $comp_root =~ m![/]$!; } sub comp_root { $comp_root } __PACKAGE__->config( comp_root => $comp_root, fixup => sub { } , skeleton => '[% skeleton %]', meat_pack => sub { my ($self, $c, $stash, $meat, $skeleton) = @_; my $body_elem = $skeleton->look_down('_tag' => 'body'); my $meat_body = $skeleton->look_down(seamstress => 'replace'); unless ($meat_body) { warn "could not find meat_body"; die $meat->as_HTML; } $meat_body->replace_content($meat->content_list); } # default sub, only runs if skeleton is true ) ; use lib $comp_root; 1;
1;