| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Text::MicroMason::PLP; | 
| 2 |  |  |  |  |  |  | # Trick PAUSE into indexing us properly: Old versions of PAUSE used | 
| 3 |  |  |  |  |  |  | # Text::MicroMason::Commands::VERSION for Text::MicroMason::PL because | 
| 4 |  |  |  |  |  |  | # they're in the same file, so PLP gained version 1.9 on PAUSE, and new | 
| 5 |  |  |  |  |  |  | # versions won't be reindexed unless they have a greater version. | 
| 6 |  |  |  |  |  |  | our $VERSION = "2.18"; | 
| 7 |  |  |  |  |  |  |  | 
| 8 | 1 |  |  | 1 |  | 678 | use strict; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 32 |  | 
| 9 | 1 |  |  | 1 |  | 6 | use Carp; | 
|  | 1 |  |  |  |  | 19 |  | 
|  | 1 |  |  |  |  | 84 |  | 
| 10 |  |  |  |  |  |  |  | 
| 11 | 1 |  |  | 1 |  | 509 | use Safe; | 
|  | 1 |  |  |  |  | 30943 |  | 
|  | 1 |  |  |  |  | 191 |  | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | ###################################################################### | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | sub lex_token { | 
| 16 |  |  |  |  |  |  | # Blocks in <: ... :> tags. | 
| 17 | 51 | 100 |  | 51 | 1 | 245 | /\G \< \: (\=)? ( .*? ) \: \> /gcxs ? ( ($1 ? 'expr' : 'perl') => $2 ) : | 
|  |  | 50 |  |  |  |  |  | 
|  |  | 50 |  |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | # Blocks in <( ... )> tags. | 
| 20 |  |  |  |  |  |  | /\G \< \( ( .*? ) \) \> /gcxs ? ( 'include' => $1 ) : | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | # Things that don't match the above | 
| 23 |  |  |  |  |  |  | /\G ( (?: [^\<]+ | \<(?![\:\(]) )? ) /gcxs ? ( 'text' => $1 ) : | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | # Lexer error | 
| 26 |  |  |  |  |  |  | () | 
| 27 |  |  |  |  |  |  | } | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | # $perl_code = $mason->assemble( @tokens ); | 
| 30 |  |  |  |  |  |  | sub assemble { | 
| 31 | 8 |  |  | 8 | 1 | 10 | my $self = shift; | 
| 32 | 8 |  |  |  |  | 18 | my @tokens = @_; | 
| 33 |  |  |  |  |  |  |  | 
| 34 | 8 |  |  |  |  | 27 | for ( my $position = 0; $position <= int( $#tokens / 2 ); $position ++ ) { | 
| 35 | 51 | 50 |  |  |  | 96 | if ( $tokens[$position * 2] eq 'include' ) { | 
| 36 | 0 |  |  |  |  | 0 | my $token = $tokens[$position * 2 + 1]; | 
| 37 | 0 |  |  |  |  | 0 | splice @tokens, $position * 2, 2, $self->lex( $self->read_file( $token ) ) | 
| 38 |  |  |  |  |  |  | } | 
| 39 |  |  |  |  |  |  | } | 
| 40 |  |  |  |  |  |  |  | 
| 41 | 8 |  |  |  |  | 23 | $self->NEXT('assemble', @tokens ); | 
| 42 |  |  |  |  |  |  | } | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | ###################################################################### | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | package Text::MicroMason::Commands; | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | # Trick PAUSE into indexing us properly: this package used to be in | 
| 49 |  |  |  |  |  |  | # MicroMason.pm, so it gained version 1.07 on PAUSE, and the new ones | 
| 50 |  |  |  |  |  |  | # won't be reindexed unless they have a greater version. | 
| 51 |  |  |  |  |  |  | our $VERSION = "1.9"; | 
| 52 |  |  |  |  |  |  |  | 
| 53 | 1 |  |  | 1 |  | 8 | use vars qw( $m ); | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 96 |  | 
| 54 |  |  |  |  |  |  | sub include { | 
| 55 | 0 |  |  | 0 |  |  | $m->execute( file => @_ ) | 
| 56 |  |  |  |  |  |  | } | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | sub Include { | 
| 59 | 0 |  |  | 0 |  |  | $m->execute( file => @_ ) | 
| 60 |  |  |  |  |  |  | } | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | sub ReadFile { | 
| 63 | 0 |  |  | 0 |  |  | $m->read_file( @_ ) | 
| 64 |  |  |  |  |  |  | } | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | sub Entity { | 
| 67 | 1 | 0 |  | 1 |  | 7 | eval { require HTML::Entities; no strict; *Entity = \&HTML::Entities::encode } | 
|  | 1 |  |  | 0 |  | 1 |  | 
|  | 1 |  |  |  |  | 52 |  | 
|  | 0 |  |  |  |  |  |  | 
|  | 0 |  |  |  |  |  |  | 
|  | 0 |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | ?  goto &HTML::Entities::encode : die "Can't load HTML::Entities"; | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  | } | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | sub EncodeURI { | 
| 73 | 1 | 0 |  | 1 |  | 5 | eval { require URI::Escape; no strict; *Entity = \&URI::Escape::uri_escape } | 
|  | 1 |  |  | 0 |  | 1 |  | 
|  | 1 |  |  |  |  | 46 |  | 
|  | 0 |  |  |  |  |  |  | 
|  | 0 |  |  |  |  |  |  | 
|  | 0 |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | ?  goto &URI::Escape::uri_escape : die "Can't load HTML::Entities"; | 
| 75 |  |  |  |  |  |  | } | 
| 76 |  |  |  |  |  |  |  | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | ###################################################################### | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | 1; | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  | __END__ |