| 1 | # Apache::XPP::Inline | ||||||||||
| 2 | # ------------- | ||||||||||
| 3 | # $Revision: 1.1 $ | ||||||||||
| 4 | # $Date: 2002/01/16 22:06:46 $ | ||||||||||
| 5 | # ----------------------------------------------------------------------------- | ||||||||||
| 6 | =head1 NAME | ||||||||||
| 7 | |||||||||||
| 8 | Apache::XPP::Inline - Use XPP as an inline source filter | ||||||||||
| 9 | |||||||||||
| 10 | =cut | ||||||||||
| 11 | |||||||||||
| 12 | package Apache::XPP::Inline; | ||||||||||
| 13 | |||||||||||
| 14 | =head1 SYNOPSIS | ||||||||||
| 15 | |||||||||||
| 16 | use Apache::XPP::Inline; | ||||||||||
| 17 | |||||||||||
| 18 | XPML CODE <?= "GOES" ?> HERE | ||||||||||
| 19 | |||||||||||
| 20 | =head1 REQUIRES | ||||||||||
| 21 | |||||||||||
| 22 | Apache::XPP | ||||||||||
| 23 | Filter::Util::Call | ||||||||||
| 24 | |||||||||||
| 25 | =cut | ||||||||||
| 26 | |||||||||||
| 27 | 1 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 28 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 29 | 1 | ▶ | use vars qw( $AUTOLOAD $debug $debuglines ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 30 | |||||||||||
| 31 | 1 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 32 | 1 | $Apache::XPP::Inline::REVISION = (qw$Revision: 1.1 $)[-1]; | |||||||||
| 33 | 1 | $Apache::XPP::Inline::VERSION = '2.02'; | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | =head1 EXPORTS | ||||||||||
| 37 | |||||||||||
| 38 | Nothing | ||||||||||
| 39 | |||||||||||
| 40 | =head1 DESCRIPTION | ||||||||||
| 41 | |||||||||||
| 42 | The Apache::XPP::Inline module allows access to XPP parsing in an inline fashion. | ||||||||||
| 43 | After a C<use Apache::XPP::Inline;> statement, the remaining source code will be | ||||||||||
| 44 | interpreted as XPML, and parsed appropriately. | ||||||||||
| 45 | |||||||||||
| 46 | =cut | ||||||||||
| 47 | |||||||||||
| 48 | 1 | ▶ | use Filter::Util::Call; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 49 | |||||||||||
| 50 | 1 | ▶ | sub import { | ||||||||
|
Subroutine
import: called CC=1 SCAR=0.1
| |||||||||||
| 51 | 1 | my $class = shift; | |||||||||
| 52 | 2 | ▶ | filter_add( sub { | ||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.1
| |||||||||||
| 53 | 2 | my $caller = caller; | |||||||||
| 54 | 2 | my $status; | |||||||||
| 55 | 2 | my $data = ''; | |||||||||
| 56 | 2 | my $code = ''; | |||||||||
| 57 | |||||||||||
| 58 | 2 | ▶ | while ($status = filter_read(1024)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 59 | 1 | ▶ | if ($status <= 0) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 60 | 0 | $_ = $code; | |||||||||
| 61 | 0 | return $status; | |||||||||
| 62 | } | ||||||||||
| 63 | |||||||||||
| 64 | 1 | $data .= $_; | |||||||||
| 65 | 1 | ▶ | if ($status < 1024) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 66 | 1 | $data =~ s/'/\\'/g; | |||||||||
| 67 | 1 | $data =~ s/\n/' . "\\n" . '/g; | |||||||||
| 68 | |||||||||||
| 69 | 1 | $code = join( "\n", | |||||||||
| 70 | "use Apache::XPP;", | ||||||||||
| 71 | "my \$code = '${data}';", | ||||||||||
| 72 | "my \$xpml = Apache::XPP->new( { source => \$code } );", | ||||||||||
| 73 | "\$xpml->run();\n" | ||||||||||
| 74 | ); | ||||||||||
| 75 | } | ||||||||||
| 76 | |||||||||||
| 77 | 1 | $_ = $code; | |||||||||
| 78 | } | ||||||||||
| 79 | |||||||||||
| 80 | 2 | return length($_); | |||||||||
| 81 | }) | ||||||||||
| 82 | 1 | } | |||||||||
| 83 | |||||||||||
| 84 | 1 | 1; | |||||||||
| 85 | |||||||||||
| 86 | __END__ | ||||||||||