| MasonX-StaticBuilder documentation | Contained in the MasonX-StaticBuilder distribution. |
MasonX::StaticBuilder::Component -- fill in a single template file
my $tmpl = MasonX::StaticBuilder::Component->new($file);
my $output = $tmpl->fill_in(%args);
print $output;
Constructor. Give it a hashref containing the following args:
Fill in the template, by running all the mason code in the template files. Any parameters passed to this method will be available to the template as named args.
For example:
$tmpl->fill_in( foo => "bar");
And in the template:
<%args>
$foo => undef
</%args>
Foo is <% $foo %>
| MasonX-StaticBuilder documentation | Contained in the MasonX-StaticBuilder distribution. |
package MasonX::StaticBuilder::Component; use strict; use warnings; use base qw(Class::Accessor); MasonX::StaticBuilder::Component->mk_accessors(qw(comp_root comp_name)); use Carp; use File::Spec; use HTML::Mason;
sub new { my ($class, $args) = @_; my $comp_root = File::Spec->rel2abs($args->{comp_root}); my $comp_name = $args->{comp_name}; my $filename = $comp_root . $comp_name; if ($filename && -e $filename && -T $filename) { my $self = {}; bless $self, $class; $self->comp_root($comp_root); $self->comp_name($comp_name); return $self; } else { return undef; } }
sub fill_in { my ($self, @args) = @_; my $output; my $interp = HTML::Mason::Interp->new( comp_root => $self->comp_root(), out_method => \$output ); $interp->exec($self->comp_name(), @args); return $output; } 1;