package Test::Inline::Content::Simple; =pod =head1 NAME Test::Inline::Content::Simple - Simple templating Content Handler =head1 SYNOPSIS In your inline2test.tpl ---------------------- #!/usr/bin/perl -w use strict; use Test::More [% plan %]; $| = 1; [% tests %] 1; =head1 DESCRIPTION It is relatively common to want to customise the contents of the generated test files to set up custom environment things on an all-scripts basis, rather than file by file (using =begin SETUP blocks). C lets you use a very simple Template Toolkit style template to define this information. It contains only two tags, C and C. The C tag will be inserted as either C 123> or C<'no_plan'>. The C tag will be replaced by the actual testing code. =head1 METHODS =cut use strict; use base 'Test::Inline::Content'; use File::Slurp (); use Params::Util qw{_INSTANCE}; use vars qw{$VERSION}; BEGIN { $VERSION = '2.208'; } ##################################################################### # Constructor and Accessors =pod =head2 new $filename Manually create a new C object. Takes as parameter a single filename which should contain the template code. Returns a new C object, or C on error. =cut sub new { my $class = ref $_[0] ? ref shift : shift; my $file = (defined $_[0] and -r $_[0]) ? shift : return undef; # Create the object my $self = $class->SUPER::new() or return undef; # Load, check and add the file my $template = File::Slurp::read_file( $file ) or return undef; $template =~ /\[%\s+tests\s+\%\]/ or return undef; # $template =~ /\[\%\s+plan\s+\%\]/ or return undef; $self->{template} = $template; $self; } =pod =head2 template The C