Apache-PSP
view release on metacpan or search on metacpan
lib/Template/PSP.pm view on Meta::CPAN
use IO::Scalar;
use DBI;
use vars qw($VERSION);
$VERSION = 1.00;
# %tags - list of special HTML tags defined in Template.pm
# %global_tags - list of HTML tags, accessible by all pages
#
# $page - scalar reference to script being created from template
# $frags - html fragments
# $outputflag - process '$' variables
# $perlflag - perl code
# $package - template is being placed in $package
# %tagdata - data associated with tag being created
# %Cache - file time stamps for loaded psp pages
# %Handler - pointers to subroutines for psp pages
# %type - subroutines for handling output types
use vars qw (%tags %global_tags $page $parsefile $frags $outputflag $perlflag
$handlerflag $package %tagdata %Cache %Handler %type $lineno
$top_package $escapeflag $space
);
use vars qw(%QUERY %CGI %FILENAMES %AUTH %COOKIE);
%tags = map {$_ => 1}
( "tag", "loop", "if", "else", "elseif", "perl", "fetch", "output",
"handler", "return", "include", "pspescape" );
lib/Template/PSP.pm view on Meta::CPAN
# on the name of the file being loaded. We run the file
# name passed to pspload through abs_path to be certain that
# the file name is uniquely defined.
sub pspload
{
my ($data, $pkg, $topflag) = @_;
my $parseflag = 0;
my $handler;
my $file;
my ($oldpage, $oldpkg, $oldfrags, $pg, $oldfile, $oldlineno);
if (!ref($data))
{
# data is a file name, not the code
# This file name may have . ../.. or a relative path
# that makes it not uniquely defined
$file = abs_path($data);
if (newfile($file))
{
lib/Template/PSP.pm view on Meta::CPAN
if ($parseflag)
{
my $parser;
my $token;
# we need to create a temporary place
# to store the page as it is building it
$oldlineno = $lineno;
$oldfile = $parsefile;
$oldfrags = $frags;
$oldpage = $page;
$oldpkg = $package;
$frags = 0;
$lineno = 1;
$package = $pkg;
$page = \$pg;
$parsefile = $file;
my $eval = "package $pkg;\n" .
'*getpvar = \&Template::PSP::getpvar;' . "\n" .
'*setpvar = \&Template::PSP::setpvar;' . "\n" .
'*cleanup = \&Template::PSP::cleanup;' . "\n" .
'use CGI::Minimal;' . "\n" .
lib/Template/PSP.pm view on Meta::CPAN
if ($file)
{
$Handler{$file} = $handler;
}
no strict 'refs';
# restore globals
$lineno = $oldlineno;
$parsefile = $oldfile;
$frags = $oldfrags;
$page = $oldpage;
$package = $oldpkg;
}
# import export_tags from loaded page
if (defined($package))
{
if (!defined($pkg))
{
$pkg = valid_package_name($file);
lib/Template/PSP.pm view on Meta::CPAN
append_page($text);
}
elsif ($outputflag)
{
$text =~ s/\@/\\\@/g;
append_page('print qq{' . $text . '};' . "\n");
}
else
{
no strict 'refs';
$frags++;
${$package . '::__html_' . $frags} = $text;
append_page("print \$" . $package . '::__html_' . $frags . ";\n");;
}
}
#########################################
# BEGIN TAG DEFINITIONS
#
# The tag TAG allows building of non-looping tags.
# three parameters can be passed:
# name - name of tag to create
( run in 0.897 second using v1.01-cache-2.11-cpan-b16cb0d3907 )