Skip to content

Instantly share code, notes, and snippets.

@petr999
Created February 1, 2010 13:00
Show Gist options
  • Save petr999/291675 to your computer and use it in GitHub Desktop.
Save petr999/291675 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl -w
use strict;
use warnings;
our $testAppRoot;
BEGIN{
use Cwd qw/realpath getcwd/;
use File::Basename qw/dirname/;
$testAppRoot = realpath( dirname( __FILE__ )."/../" );
my $testAppLib = realpath "$testAppRoot/lib";
unshift( @INC, $testAppLib ) unless grep { $_ eq $testAppLib } @INC;
}
use TestApp;
use Cwd qw/realpath getcwd/;
use File::Basename qw/dirname/;
use CGI;
use CGI::Carp qw/fatalsToBrowser/;
print CGI->header;
TestApp::test00;
1;
<TMPL_INCLUDE NAME="header.tmpl">
TEST00 Template
<TMPL_INCLUDE NAME="footer.tmpl">
#!/usr/bin/perl -w
use strict;
use warnings;
our $testAppRoot;
BEGIN{
use Cwd qw/realpath getcwd/;
use File::Basename qw/dirname/;
$testAppRoot = realpath( dirname( __FILE__ )."/../" );
my $testAppLib = realpath "$testAppRoot/lib";
unshift( @INC, $testAppLib ) unless grep { $_ eq $testAppLib } @INC;
}
use TestApp;
use Cwd qw/realpath getcwd/;
use File::Basename qw/dirname/;
use CGI;
use CGI::Carp qw/fatalsToBrowser/;
my $tmpl_lib = realpath( dirname( __FILE__ )."/../tmpl" );
print CGI->header;
TestApp::test01;
1;
<TMPL_INCLUDE NAME="header.tmpl">
TEST01 Template
<TMPL_INCLUDE NAME="footer.tmpl">
package TestApp;
use strict;
use warnings;
use Cwd qw/realpath getcwd/;
use HTML::Template;
use FCGI::Spawn;
my $tmpl_lib = realpath( $main::testAppRoot."/tmpl" );
my( $header_fn, $footer_fn ) = map { join '/', $tmpl_lib, $_ } ( 'footer.tmpl', 'header.tmpl' );
sub tmpl_page{
my $tmpl = HTML::Template->new( filename => shift, ) or die $!;
# $tmpl->ExpireTime( 0 );
return $tmpl;
}
sub test{
my $template_fn = join '/', $tmpl_lib, shift ;
my $template = FCGI::Spawn::xinc(
[ $template_fn, $header_fn, $footer_fn, ]
=> \&tmpl_page,
);
$template->output( print_to => \*STDOUT, );
}
sub test00{
test 'test00.tmpl';
}
sub test01{
test 'test01.tmpl';
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment