use vars qw($VERSION);
BEGIN {
- $VERSION = '2.08';
+ $VERSION = '2.09';
Time::HiRes->import('time') if eval {require Time::HiRes};
eval {require Scalar::Util};
my $args = $self->run_hook('template_args', $step);
my $copy = $self;
eval {require Scalar::Util; Scalar::Util::weaken($copy)};
- $args->{'INCLUDE_PATH'} ||= sub { $copy->base_dir_abs || die "Could not find base_dir_abs while looking for template INCLUDE_PATH on step \"$step\"" };
-
- require CGI::Ex::Template;
- my $t = CGI::Ex::Template->new($args);
+ $args->{'INCLUDE_PATH'} ||= sub {
+ my $dir = $copy->base_dir_abs || die "Could not find base_dir_abs while looking for template INCLUDE_PATH on step \"$step\"";
+ $dir = $dir->() if UNIVERSAL::isa($dir, 'CODE');
+ return $dir;
+ };
+ my $t = $self->template_obj($args);
my $out = '';
+
$t->process($file, $swap, \$out) || die $t->error;
return $out;
sub template_args { {} }
+sub template_obj {
+ my ($self, $args) = @_;
+
+ require CGI::Ex::Template;
+ my $t = CGI::Ex::Template->new($args);
+}
+
sub fill_template {
my ($self, $step, $outref, $fill) = @_;
sub post_print { 0 }
sub post_step { 0 } # success indicates we handled step (don't continue step or loop)
-sub name_step {
- my ($self, $step) = @_;
- return $step;
-}
-
sub morph_package {
my $self = shift;
my $step = shift || '';
};
}
+sub name_step {
+ my ($self, $step) = @_;
+ return $step;
+}
+
sub file_print {
my $self = shift;
my $step = shift;
my $self = shift;
my $step = shift;
- my $abs = $self->base_dir_abs || return {};
+ ### determine the path to begin looking for files - allow for an arrayref
+ my $abs = $self->base_dir_abs || [];
+ $abs = $abs->() if UNIVERSAL::isa($abs, 'CODE');
+ $abs = [$abs] if ! UNIVERSAL::isa($abs, 'ARRAY');
+ return {} if @$abs == 0;
+
my $base_dir = $self->base_dir_rel;
my $module = $self->run_hook('name_module', $step);
- my $_step = $self->run_hook('name_step', $step);
+ my $_step = $self->run_hook('name_step', $step) || die "Missing name_step";
$_step .= '.'. $self->ext_val if $_step !~ /\.\w+$/;
- foreach ($abs, $base_dir, $module) { $_ .= '/' if length($_) && ! m|/$| }
+ foreach (@$abs, $base_dir, $module) { $_ .= '/' if length($_) && ! m|/$| }
+
+ if (@$abs > 1) {
+ foreach my $_abs (@$abs) {
+ my $path = $_abs . $base_dir . $module . $_step;
+ return $path if -e $path;
+ }
+ }
- return $abs . $base_dir . $module . $_step;
+ return $abs->[0] . $base_dir . $module . $_step;
}
sub info_complete {
return $self->{'base_dir_abs'} || '';
}
-sub ext_val {
- my $self = shift;
- $self->{'ext_val'} = shift if $#_ != -1;
- return $self->{'ext_val'} || 'val';
-}
-
sub ext_print {
my $self = shift;
$self->{'ext_print'} = shift if $#_ != -1;
return $self->{'ext_print'} || 'html';
}
+sub ext_val {
+ my $self = shift;
+ $self->{'ext_val'} = shift if $#_ != -1;
+ return $self->{'ext_val'} || 'val';
+}
+
### where to find the javascript files
### default to using this script as a handler
sub js_uri_path {