Created
February 1, 2010 13:00
-
-
Save petr999/291675 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<TMPL_INCLUDE NAME="header.tmpl"> | |
TEST00 Template | |
<TMPL_INCLUDE NAME="footer.tmpl"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<TMPL_INCLUDE NAME="header.tmpl"> | |
TEST01 Template | |
<TMPL_INCLUDE NAME="footer.tmpl"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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