App-Basis-ConvertText2
view release on metacpan or search on metacpan
lib/App/Basis/ConvertText2.pm view on Meta::CPAN
<head>
<title>$TITLE</title>
<style type='text/css'>
\@page { size: A4 }
</style>
</head>
<body>
<h1>%TITLE%</h1>
%_CONTENTS_%
</body>
</html>\n";
},
);
has 'replace' => (
is => 'ro',
default => sub { {} },
);
has 'verbose' => (
is => 'ro',
default => sub {0},
);
has '_output' => (
is => 'ro',
default => sub {""},
init_arg => 0
);
has '_input' => (
is => 'ro',
writer => '_set_input',
default => sub {""},
init_arg => 0
);
has '_md5id' => (
is => 'ro',
writer => '_set_md5id',
default => sub {""},
init_arg => 0
);
has 'embed' => (
is => 'ro',
default => sub {0},
);
# ----------------------------------------------------------------------------
=item new
Create a new instance of a of a data formating object
B<Parameters> passed in a HASH
name - name of this formatting action - required
basedir - root directory of document being processed
cache_dir - place to store cache files - optional
use_cache - decide if you want to use a cache or not
template - HTML template to use, must contain %_CONTENTS_%
replace - hashref of extra keywords to use as replaceable variables
verbose - be verbose
embed - embed images, do not create links to them
=cut
sub BUILD {
my $self = shift;
die "No name provided" if ( !$self->name() );
if ( $self->use_cache() ) {
# need to add the name to the cache dirname to make it distinct
$self->_set_cache_dir( fix_filename( $self->cache_dir() . "/" . $self->name() ) );
if ( !-d $self->cache_dir() ) {
# create the cache dir if needed
try {
path( $self->cache_dir() )->mkpath;
}
catch {};
die "Could not create cache dir " . $self->cache_dir() if ( !-d $self->cache_dir() );
}
}
# work out what plugins do what
foreach my $plug ( $self->plugins() ) {
my $obj = $plug->new();
if ( !$obj ) {
warn "Plugin $plug does not instantiate";
next;
}
# the process method does the work for all the tag handlers
if ( !$obj->can('process') ) {
warn "Plugin $plug does not provide a process method";
next;
}
foreach my $h ( @{ $obj->handles } ) {
$h = lc($h);
if ( $h eq 'buffer' ) {
die "Plugin $plug cannot provide a handler for $h, as this is already provided for internally";
}
if ( $valid_tags{$h} ) {
die "Plugin $plug cannot provide a handler for $h, as this is already provided by $valid_tags{ $h }";
}
# all handlers are lower case
$valid_tags{$h} = $obj;
}
}
# buffer is a special internal handler
$valid_tags{buffer} = 1;
}
# ----------------------------------------------------------------------------
( run in 1.672 second using v1.01-cache-2.11-cpan-97f6503c9c8 )