| 1 | package App::ZofCMS::Plugin::FileToTemplate; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | our $VERSION = '1.001010'; # VERSION | |||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use Data::Transformer; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use File::Spec; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 0 | ▶ | sub new { bless {}, shift } | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 12 | |||||||||||
| 13 | 1 | my $Template_Dir; | |||||||||
| 14 | |||||||||||
| 15 | 0 | ▶ | sub process { | ||||||||
|
Subroutine
process: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 16 | 0 | my ( $self, $template, $query, $config ) = @_; | |||||||||
| 17 | |||||||||||
| 18 | 0 | $Template_Dir = $config->conf->{templates}; | |||||||||
| 19 | |||||||||||
| 20 | 0 | my $t = Data::Transformer->new( normal => \&callback ); | |||||||||
| 21 | 0 | $t->traverse( $template ); | |||||||||
| 22 | } | ||||||||||
| 23 | |||||||||||
| 24 | 0 | ▶ | sub callback { | ||||||||
|
Subroutine
callback: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||
| 25 | 0 | my $in = shift; | |||||||||
| 26 | |||||||||||
| 27 | 0 | ▶ | while ( my ( $t ) = $$in =~ /<FTTR:([^>]+)>/ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | 0 | my $tag_result; | |||||||||
| 29 | 0 | my $file = File::Spec->catfile( $Template_Dir, $t ); | |||||||||
| 30 | 0 | ▶ | if ( open my $fh, '<', $file ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 0 | $tag_result = do { local $/; <$fh>; }; | |||||||||
| 32 | } | ||||||||||
| 33 | else { | ||||||||||
| 34 | 0 | $tag_result = $!; | |||||||||
| 35 | } | ||||||||||
| 36 | 0 | $$in =~ s/<FTTR:[^>]+>/$tag_result/; | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 0 | ▶ | if ( my ( $t ) = $$in =~ /<FTTD:([^>]+)>/ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 0 | my $tag_result; | |||||||||
| 41 | 0 | my $file = File::Spec->catfile( $Template_Dir, $t ); | |||||||||
| 42 | |||||||||||
| 43 | 0 | ▶ | $tag_result = do $file | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | or $tag_result = "ERROR: $! $@"; | ||||||||||
| 45 | |||||||||||
| 46 | 0 | $$in = $tag_result; | |||||||||
| 47 | } | ||||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 1 | 1; | |||||||||
| 51 | __END__ | ||||||||||