Apache::XPP::Inline - Use XPP as an inline source filter


Apache-XPP documentation Contained in the Apache-XPP distribution.

Index


Code Index:

NAME

Top

Apache::XPP::Inline - Use XPP as an inline source filter

SYNOPSIS

Top

 use Apache::XPP::Inline;

 XPML CODE <?= "GOES" ?> HERE

REQUIRES

Top

 Apache::XPP
 Filter::Util::Call

EXPORTS

Top

Nothing

DESCRIPTION

Top

The Apache::XPP::Inline module allows access to XPP parsing in an inline fashion. After a use Apache::XPP::Inline; statement, the remaining source code will be interpreted as XPML, and parsed appropriately.

REVISION HISTORY

Top

$Log: Inline.pm,v $

SEE ALSO

Top

perl(1).

KNOWN BUGS

Top

None

COPYRIGHT

Top

AUTHORS

Top

 Gregory Williams <greg@evilfunhouse.com>


Apache-XPP documentation Contained in the Apache-XPP distribution.
# Apache::XPP::Inline
# -------------
# $Revision: 1.1 $
# $Date: 2002/01/16 22:06:46 $
# -----------------------------------------------------------------------------
package Apache::XPP::Inline;

use Carp;
use strict;
use vars qw( $AUTOLOAD $debug $debuglines );

BEGIN {
    $Apache::XPP::Inline::REVISION	= (qw$Revision: 1.1 $)[-1];
    $Apache::XPP::Inline::VERSION	= '2.02';
}

use Filter::Util::Call;

sub import {
	my $class	= shift;
	filter_add( sub {
		my $caller	= caller;
		my $status;
		my $data	= '';
		my $code	= '';
		
		while ($status = filter_read(1024)) {
			if ($status <= 0) {
				$_	= $code;
				return $status;
			}
			
			$data	.= $_;
			if ($status < 1024) {
				$data	=~ s/'/\\'/g;
				$data	=~ s/\n/' . "\\n" . '/g;
				
				$code	= join( "\n",
								"use Apache::XPP;",
								"my \$code = '${data}';",
								"my \$xpml = Apache::XPP->new( { source => \$code } );",
								"\$xpml->run();\n"
							);
			}
			
			$_		= $code;
		}
		
		return length($_);
	})
}

1;

__END__