| 1 | package HTML::Template::Filter::Dreamweaver; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||
| 6 | 1 | require Exporter; | |||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use AutoLoader qw(AUTOLOAD); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | 1 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||
| 11 | # Items to export into callers namespace by default. Note: do not export | ||||||||||||||||||||||||||||||||
| 12 | # names by default without a very good reason. Use EXPORT_OK instead. | ||||||||||||||||||||||||||||||||
| 13 | # Do not simply export all your public functions/methods/constants. | ||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | # This allows declaration use HTML::Template::Filter::Dreamweaver ':all'; | ||||||||||||||||||||||||||||||||
| 16 | # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK | ||||||||||||||||||||||||||||||||
| 17 | # will save memory. | ||||||||||||||||||||||||||||||||
| 18 | 1 | our %EXPORT_TAGS = ( 'all' => [ qw( DWT2HTML DWT2HTMLExpr | |||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | ) ] ); | ||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | 1 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | |||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||
| 24 | 1 | our @EXPORT = qw( | |||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||||||
| 27 | 1 | our $VERSION = '1.01'; | |||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | # Preloaded methods go here. | ||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | # Autoload methods go after =cut, and are processed by the autosplit program. | ||||||||||||||||||||||||||||||||
| 33 | 232 | ▶ | sub escapeQuote { | ||||||||||||||||||||||||||||||
|
Subroutine
escapeQuote: called CC=3 SCAR=11.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 34 | 232 | my $toencode = shift; | |||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||
| 36 | 232 | ▶ | if ( $toencode !~ /\'/ ) { return "'$toencode'"; } | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 37 | 61 | elsif ( $toencode !~ /\"/ ) { return "\"$toencode\""; } | |||||||||||||||||||||||||||||||
| 38 | else { | ||||||||||||||||||||||||||||||||
| 39 | 0 | $toencode =~ s{\"}{\'}gso; | |||||||||||||||||||||||||||||||
| 40 | 0 | return "\"$toencode\""; | |||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||
| 44 | 6 | ▶ | sub handleTemplateEditable { | ||||||||||||||||||||||||||||||
|
Subroutine
handleTemplateEditable: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 45 | 6 | my $str = shift; | |||||||||||||||||||||||||||||||
| 46 | 6 | my $default = shift; | |||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||
| 48 | 6 | my $ret = "<!-- TMPL_VAR"; | |||||||||||||||||||||||||||||||
| 49 | 6 | my $name; | |||||||||||||||||||||||||||||||
| 50 | 6 | ▶ | if ( $str =~ m{\s[Nn][Aa][Mm][Ee]\s*=\s*([\"\'])(.*?)\1}s ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 51 | 6 | $name = $2; | |||||||||||||||||||||||||||||||
| 52 | 6 | $ret .= " NAME=$1$2$1"; | |||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||
| 55 | 6 | ▶ | if ( $str =~ m{\s[Ee][Ss][Cc][Aa][Pp][Ee]\s*=\s*([\"\'])(.*?)\1}s ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 56 | 4 | $ret .= " ESCAPE=$2"; | |||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||
| 59 | 6 | if ( 0 && $default ) { | |||||||||||||||||||||||||||||||
| 60 | $ret .= " DEFAULT=" . escapeQuote($default); | ||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||
| 63 | 6 | $ret .= " -->"; | |||||||||||||||||||||||||||||||
| 64 | 6 | return $ret; | |||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||
| 67 | 3 | ▶ | sub handleTernary { | ||||||||||||||||||||||||||||||
|
Subroutine
handleTernary: called CC=9 SCAR=24.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 68 | 3 | my $str = shift; | |||||||||||||||||||||||||||||||
| 69 | 3 | my $defaults = shift; | |||||||||||||||||||||||||||||||
| 70 | 3 | my $use_expr = shift; | |||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||
| 72 | 3 | my ( $char, $expr ) = $str =~ m{\s[Ee][Xx][Pp][Rr]\s*=\s*([\"\'])(.*?)\1}s; | |||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||
| 74 | 3 | my ( $if, $true, $false ) = $expr =~ m{(.*)\?(.*)\:(.*)}; | |||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||
| 76 | 3 | $if =~ s/^\s+//g; | |||||||||||||||||||||||||||||||
| 77 | 3 | $if =~ s/\s+$//g; | |||||||||||||||||||||||||||||||
| 78 | 3 | $true =~ s/^\s+//g; | |||||||||||||||||||||||||||||||
| 79 | 3 | $true =~ s/\s+$//g; | |||||||||||||||||||||||||||||||
| 80 | 3 | $false =~ s/^\s+//g; | |||||||||||||||||||||||||||||||
| 81 | 3 | $false =~ s/\s+$//g; | |||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||
| 83 | 3 | ▶ | while ( $true =~ m{([\w\'\"]+)}sg ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 84 | 3 | ▶ | if ( $defaults->{ $1 } ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 85 | 0 | $true = handleTemplateExpr( "cond=" . escapeQuote($true), $defaults, $use_expr ); | |||||||||||||||||||||||||||||||
| 86 | 0 | last; | |||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||
| 90 | 3 | ▶ | while ( $false =~ m{([\w\'\"]+)}sg ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 91 | 3 | ▶ | if ( $defaults->{ $1 } ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 92 | 0 | $false = handleTemplateExpr( "cond=" . escapeQuote($false), $defaults, $use_expr ); | |||||||||||||||||||||||||||||||
| 93 | 0 | last; | |||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||
| 97 | 3 | ▶ | $true = "" if $true eq '""' || $true eq "''"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$true eq "\"\"" or $true eq "''"
MC/DC0%0/2
$true eq "\"\"" or $true eq "''"
$true eq "\"\""
$true eq "''"
Truth table33%1/3
A or B
A= $true eq "\"\""B= $true eq "''"
| |||||||||||||||||||||||||||||||||
| 98 | 3 | ▶ | $false = "" if $false eq '""' || $false eq "''"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$false eq "\"\"" or $false eq "''"
MC/DC0%0/2
$false eq "\"\"" or $false eq "''"
$false eq "\"\""
$false eq "''"
Truth table33%1/3
A or B
A= $false eq "\"\""B= $false eq "''"
| |||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||
| 100 | 3 | return "<!-- TemplateBeginIf cond=$char$if$char -->$true<TMPL_ELSE>$false<!-- TemplateEndIf -->"; | |||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||
| 103 | 244 | ▶ | sub handleTemplateExpr { | ||||||||||||||||||||||||||||||
|
Subroutine
handleTemplateExpr: called CC=9 SCAR=22.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 104 | 244 | my $str = shift; | |||||||||||||||||||||||||||||||
| 105 | 244 | my $defaults = shift; | |||||||||||||||||||||||||||||||
| 106 | 244 | my $use_expr = shift; | |||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||
| 108 | 244 | my $ret = "<!-- TMPL_VAR"; | |||||||||||||||||||||||||||||||
| 109 | 244 | my $name; | |||||||||||||||||||||||||||||||
| 110 | 244 | ▶ | if ( $str =~ m{\s[Ee][Xx][Pp][Rr]\s*=\s*([\"\'])(.*?)\1}s ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 111 | 244 | $name = $2; | |||||||||||||||||||||||||||||||
| 112 | 244 | $name =~ s/^\s+//s; | |||||||||||||||||||||||||||||||
| 113 | 244 | $name =~ s/\s+$//s; | |||||||||||||||||||||||||||||||
| 114 | 244 | ▶ | if ( $name =~ m{\?.*\:.+} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 115 | 3 | return handleTernary( $str, $defaults, $use_expr ); | |||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||
| 117 | 241 | ▶ | if ( !$use_expr || exists( $defaults->{ $name } ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $use_expr or exists $defaults->{$name}
MC/DC0%0/2
not $use_expr or exists $defaults->{$name}
not $use_expr
exists $defaults->{$name}
Truth table66%2/3
not(A) or B
A= not $use_exprB= exists $defaults->{$name}
| |||||||||||||||||||||||||||||||||
| 118 | 241 | $ret .= " NAME=$1$name$1"; | |||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||
| 120 | else { | ||||||||||||||||||||||||||||||||
| 121 | 0 | $ret .= " EXPR=$1$name$1"; | |||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||
| 125 | 241 | ▶ | if ( $str =~ m{\s[Ee][Ss][Cc][Aa][Pp][Ee]\s*=\s*([\"\'])(.*?)\1}s ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 126 | 176 | ▶ | $ret .= " ESCAPE=$2" if $2; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||
| 128 | elsif ( $defaults->{ $name }->{ ESCAPE } ) { | ||||||||||||||||||||||||||||||||
| 129 | 32 | $ret .= " ESCAPE=$defaults->{ $name }->{ ESCAPE }"; | |||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||
| 132 | 241 | ▶ | if ( $defaults->{ $name }->{ DEFAULT } ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 133 | 180 | $ret .= " DEFAULT=" . escapeQuote($defaults->{ $name }->{ DEFAULT }); | |||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||
| 136 | 241 | $ret .= " -->"; | |||||||||||||||||||||||||||||||
| 137 | 241 | return $ret; | |||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||
| 140 | 35 | ▶ | sub handleTemplateIf { | ||||||||||||||||||||||||||||||
|
Subroutine
handleTemplateIf: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 141 | 35 | my $str = shift; | |||||||||||||||||||||||||||||||
| 142 | 35 | my $character = shift; | |||||||||||||||||||||||||||||||
| 143 | 35 | my $defaults = shift; | |||||||||||||||||||||||||||||||
| 144 | 35 | my $use_expr = shift; | |||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||
| 146 | 35 | my $ret = ""; | |||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||
| 148 | 35 | $str =~ s/^\s+//s; | |||||||||||||||||||||||||||||||
| 149 | 35 | $str =~ s/\s+$//s; | |||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||
| 151 | 35 | ▶ | if ( $str =~ m{^\!} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 152 | 4 | $ret = "<TMPL_BEGIN_UNLESS"; | |||||||||||||||||||||||||||||||
| 153 | 4 | $str =~ s/^\!//; | |||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||
| 155 | else { | ||||||||||||||||||||||||||||||||
| 156 | 31 | $ret = "<TMPL_BEGIN_IF"; | |||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||
| 159 | 35 | ▶ | if ( !$use_expr || exists( $defaults->{ $str } ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $use_expr or exists $defaults->{$str}
MC/DC50%1/2
not $use_expr or exists $defaults->{$str}
not $use_expr
exists $defaults->{$str}
Truth table66%2/3
not(A) or B
A= not $use_exprB= exists $defaults->{$str}
| |||||||||||||||||||||||||||||||||
| 160 | 11 | $ret .= " NAME=$character$str$character"; | |||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||
| 162 | else { | ||||||||||||||||||||||||||||||||
| 163 | 24 | my %words; | |||||||||||||||||||||||||||||||
| 164 | 24 | my $hasText = 0; | |||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||
| 166 | 24 | ▶ | while ( $str =~ m{([\w\'\"]+)}sg ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 167 | 33 | ▶ | if ( $defaults->{ $1 } && $defaults->{ $1 }->{ TYPE } eq "text" ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$defaults->{$1} and $defaults->{$1}{"TYPE"} eq "text"
MC/DC50%1/2
$defaults->{$1} and $defaults->{$1}{"TYPE"} eq "text"
$defaults->{$1}
$defaults->{$1}{"TYPE"} eq "text"
Truth table66%2/3
A and B
A= $defaults->{$1}B= $defaults->{$1}{"TYPE"} eq "text"
| |||||||||||||||||||||||||||||||||
| 168 | 15 | $hasText = 1; | |||||||||||||||||||||||||||||||
| 169 | 15 | last; | |||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||
| 173 | 24 | ▶ | if ( $hasText ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 174 | 15 | $str =~ s/\s*\=\=\s*/ eq /sg; | |||||||||||||||||||||||||||||||
| 175 | 15 | $str =~ s/\s*\!\=\s*/ ne /sg; | |||||||||||||||||||||||||||||||
| 176 | 15 | $str =~ s/\s*\<\=\>\s*/ cmp /sg; | |||||||||||||||||||||||||||||||
| 177 | 15 | $str =~ s/\s*\>\=\s*/ ge /sg; | |||||||||||||||||||||||||||||||
| 178 | 15 | $str =~ s/\s*\>\s*/ gt /sg; | |||||||||||||||||||||||||||||||
| 179 | 15 | $str =~ s/\s*\<\=\s*/ le /sg; | |||||||||||||||||||||||||||||||
| 180 | 15 | $str =~ s/\s*\<\s*/ lt /sg; | |||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||
| 183 | 24 | $ret .= " EXPR=$character$str$character"; | |||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||
| 186 | 35 | $ret .= ">"; | |||||||||||||||||||||||||||||||
| 187 | 35 | return $ret; | |||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||
| 190 | 1 | ▶ | sub addEndifs { | ||||||||||||||||||||||||||||||
|
Subroutine
addEndifs: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 191 | 1 | my $str = shift; | |||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||
| 193 | 1 | my $begins = 0; | |||||||||||||||||||||||||||||||
| 194 | 1 | my $ends = 0; | |||||||||||||||||||||||||||||||
| 195 | 1 | ▶ | while ( $str =~ m{<TMPL_BEGIN_(?:IF|UNLESS)}g ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 196 | 4 | $begins++; | |||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||
| 199 | 1 | ▶ | while ( $str =~ m{</TMPL_END_IF_UNLESS>}g ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 200 | 0 | $ends++; | |||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||
| 203 | 1 | $str .= ( "</TMPL_END_IF_UNLESS>" x ($begins - $ends) ); | |||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||
| 206 | 257 | ▶ | sub DWT2HTML { | ||||||||||||||||||||||||||||||
|
Subroutine
DWT2HTML: called CC=20 SCAR=30.4
Pod
documented
| |||||||||||||||||||||||||||||||||
| 207 | 257 | my $dwt = shift; | |||||||||||||||||||||||||||||||
| 208 | 257 | ▶ | my $force_template_expr = shift || 0; | ||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || 0
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||
| 210 | 257 | ▶ | my $using_template_expr = caller(6) && caller(6) eq "HTML::Template::Expr" ? 1 : 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
caller 6 and caller 6 eq "HTML::Template::Expr"
MC/DC0%0/2
caller 6 and caller 6 eq "HTML::Template::Expr"
caller 6
caller 6 eq "HTML::Template::Expr"
Truth table33%1/3
A and B
A= caller 6B= caller 6 eq "HTML::Template::Expr"
| |||||||||||||||||||||||||||||||||
| 211 | 257 | ▶ | $using_template_expr ||= $force_template_expr; | ||||||||||||||||||||||||||||||
|
Condition66%2/3
$using_template_expr ||= $force_template_expr
MC/DC50%1/2
$using_template_expr ||= $force_template_expr
$using_template_expr
$force_template_expr
Truth table66%2/3
A ||= B
A= $using_template_exprB= $force_template_expr
| |||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||
| 213 | 257 | my %params = ( "_isFirst" => {}, | |||||||||||||||||||||||||||||||
| 214 | "_isLast" => {}, | ||||||||||||||||||||||||||||||||
| 215 | "_index" => {}, | ||||||||||||||||||||||||||||||||
| 216 | ); | ||||||||||||||||||||||||||||||||
| 217 | 257 | ▶ | while ( $$dwt =~ /<!--\s*[Tt][Ee][Mm][Pp][Ll][Aa][Tt][Ee][Pp][Aa][Rr][Aa][Mm](.*?)-->/g ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 218 | 243 | my $text = $1; | |||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||
| 220 | 243 | my $name; | |||||||||||||||||||||||||||||||
| 221 | 243 | ▶ | if ( $text =~ m{\s[Nn][Aa][Mm][Ee]=([\'\"])(.*?)\1} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 222 | 243 | $name = $2; | |||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||
| 224 | else { | ||||||||||||||||||||||||||||||||
| 225 | 0 | next; | |||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||
| 228 | 243 | my $val = ""; | |||||||||||||||||||||||||||||||
| 229 | 243 | ▶ | if ( $text =~ m{\s[Vv][Aa][Ll][Uu][Ee]=([\'\"])(.*?)\1} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 230 | 243 | $val = $2; | |||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||
| 232 | # else { | ||||||||||||||||||||||||||||||||
| 233 | # next; | ||||||||||||||||||||||||||||||||
| 234 | # } | ||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||
| 236 | 243 | my $type = ""; | |||||||||||||||||||||||||||||||
| 237 | 243 | ▶ | if ( $text =~ m{\s[Tt][Yy][Pp][Ee]=([\'\"])(.*?)\1} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 238 | 243 | $type = $2; | |||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||
| 241 | 243 | my $escape = ""; | |||||||||||||||||||||||||||||||
| 242 | 243 | ▶ | if ( $text =~ m{\s[Ee][Ss][Cc][Aa][Pp][Ee]=([\'\"])(.*?)\1} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 243 | 160 | $escape = $2; | |||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||
| 246 | 243 | ▶ | if ( lc($type) eq "boolean" ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | $val = lc($val) eq "false" ? 1 : 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||
| 250 | 243 | ▶ | $params{ $name } = { DEFAULT => $val || "", | ||||||||||||||||||||||||||||||
|
Condition83%5/6
$val || ''
$escape || ''
$type || ''
MC/DC100%1/1
$val || ''
$val
MC/DC100%1/1
$escape || ''
$escape
MC/DC0%0/1
$type || ''
$type
Truth table100%2/2
A
A= $val
Truth table100%2/2
A
A= $escape
Truth table50%1/2
A
A= $type
| |||||||||||||||||||||||||||||||||
| 251 | ESCAPE => $escape || "", | ||||||||||||||||||||||||||||||||
| 252 | TYPE => lc($type || ""), | ||||||||||||||||||||||||||||||||
| 253 | }; | ||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||
| 256 | 257 | $$dwt =~ s/\@\@\(\s*_document._Get\(\s*([\'\"])(.*?)\1\s*\,\s*([\'\"])(.*?)\3\s*\)\s*\)\@\@/<!-- TemplateExpr expr=$1$2$1 ESCAPE=$3$4$3 -->/sg; | |||||||||||||||||||||||||||||||
| 257 | 257 | $$dwt =~ s/\@\@\(\s*_document._Get\(\s*([\'\"])(.*?)\1\s*\)\s*\)\@\@/<!-- TemplateExpr expr=$1$2$1 -->/sg; | |||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||
| 259 | 257 | $$dwt =~ s/_document\[([\'\"])(.*?)\1\]/$2/sg; | |||||||||||||||||||||||||||||||
| 260 | 257 | $$dwt =~ s/_repeat\[([\'\"])(.*?)\1\]/$2/sg; | |||||||||||||||||||||||||||||||
| 261 | 257 | $$dwt =~ s/<!--\s*[Tt][Ee][Mm][Pp][Ll][Aa][Tt][Ee][Pp][Aa][Rr][Aa][Mm].*?-->\s*//sg; | |||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||
| 263 | # TemplateBeginEditable | ||||||||||||||||||||||||||||||||
| 264 | 257 | $$dwt =~ s{<!--\s*[Tt][Ee][Mm][Pp][Ll][Aa][Tt][Ee][Bb][Ee][Gg][Ii][Nn][Ee][Dd][Ii][Tt][Aa][Bb][Ll][Ee](.*?)-->(.*?)<!--\s*[Tt][Ee][Mm][Pp][Ll][Aa][Tt][Ee][Ee][Nn][Dd][Ee][Dd][Ii][Tt][Aa][Bb][Ll][Ee]\s*-->}{handleTemplateEditable( $1, $2 )}esg; | |||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||
| 266 | 257 | $$dwt =~ s{\@\@\((.*?)\)\@\@}{ my $var = $1; | |||||||||||||||||||||||||||||||
| 267 | 52 | $var =~ s/^\s+//s; | |||||||||||||||||||||||||||||||
| 268 | 52 | $var =~ s/\s+$//s; | |||||||||||||||||||||||||||||||
| 269 | sprintf( "<!-- TemplateExpr expr=%s%s -->", | ||||||||||||||||||||||||||||||||
| 270 | escapeQuote($var), | ||||||||||||||||||||||||||||||||
| 271 | 52 | ▶ | $params{$var} && $params{$var}->{ ESCAPE } ? " ESCAPE='$params{$var}->{ ESCAPE}'" : "", | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$params{$var} and $params{$var}{"ESCAPE"}
MC/DC100%2/2
$params{$var} and $params{$var}{"ESCAPE"}
$params{$var}
$params{$var}{"ESCAPE"}
Truth table100%3/3
A and B
A= $params{$var}B= $params{$var}{"ESCAPE"}
| |||||||||||||||||||||||||||||||||
| 272 | ) | ||||||||||||||||||||||||||||||||
| 273 | }esg; | ||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||
| 275 | # TemplateExpr | ||||||||||||||||||||||||||||||||
| 276 | 257 | $$dwt =~ s{<!--\s*[Tt][Ee][Mm][Pp][Ll][Aa][Tt][Ee][Ee][Xx][Pp][Rr](.*?)-->}{handleTemplateExpr($1, \%params, $using_template_expr)}esg; | |||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||
| 278 | # TemplateBeginIf Cond= | ||||||||||||||||||||||||||||||||
| 279 | 257 | $$dwt =~ s{<!--\s*[Tt][Ee][Mm][Pp][Ll][Aa][Tt][Ee][Bb][Ee][Gg][Ii][Nn][Ii][Ff]\s+[Cc][Oo][Nn][Dd]\s*=\s*([\"\'])(.*?)\1\s*-->}{handleTemplateIf($2, $1, \%params, $using_template_expr )}esg; | |||||||||||||||||||||||||||||||
| 280 | # TemplateEndIf | ||||||||||||||||||||||||||||||||
| 281 | 257 | $$dwt =~ s{<!--\s*[Tt][Ee][Mm][Pp][Ll][Aa][Tt][Ee][Ee][Nn][Dd][Ii][Ff]\s*-->}{</TMPL_END_IF_UNLESS>}sg; | |||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||
| 283 | # IgnoreTemplateBeginIf Cond= NOTE: this is not a real dreamweaver tag, but we need it because dreamweaver doesn't | ||||||||||||||||||||||||||||||||
| 284 | # like to have TemplateBeginIf tags before the <body> tag | ||||||||||||||||||||||||||||||||
| 285 | 257 | $$dwt =~ s{<!--\s*[Ii][Gg][Nn][Oo][Rr][Ee][Tt][Ee][Mm][Pp][Ll][Aa][Tt][Ee][Bb][Ee][Gg][Ii][Nn][Ii][Ff]\s+[Cc][Oo][Nn][Dd]\s*=\s*([\"\'])(.*?)\1\s*-->}{handleTemplateIf($2, $1, \%params, $using_template_expr )}esg; | |||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||
| 287 | # IgnoreTemplateEndIf NOTE: Like the IgnoreTemplateBeginIf tag, this tag is not a real dreamweaver tag | ||||||||||||||||||||||||||||||||
| 288 | 257 | $$dwt =~ s{<!--\s*[Ii][Gg][Nn][Oo][Rr][Ee][Tt][Ee][Mm][Pp][Ll][Aa][Tt][Ee][Ee][Nn][Dd][Ii][Ff]\s*-->}{</TMPL_END_IF_UNLESS>}sg; | |||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||
| 290 | # TemplateBeginMultipleIf | ||||||||||||||||||||||||||||||||
| 291 | 257 | $$dwt =~ s{<!--\s*[Tt][Ee][Mm][Pp][Ll][Aa][Tt][Ee][Bb][Ee][Gg][Ii][Nn][Mm][Uu][Ll][Tt][Ii][Pp][Ll][Ee][Ii][Ff]\s*-->}{<!-- TemplateBeginMultipleIf -->}sg; | |||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||
| 293 | # TemplateEndMultipleIf | ||||||||||||||||||||||||||||||||
| 294 | 257 | $$dwt =~ s{<!--\s*[Tt][Ee][Mm][Pp][Ll][Aa][Tt][Ee][Ee][Nn][Dd][Mm][Uu][Ll][Tt][Ii][Pp][Ll][Ee][Ii][Ff]\s*-->}{<!-- TemplateEndMultipleIf -->}sg; | |||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||
| 296 | # TemplateBeginIfClause Cond= | ||||||||||||||||||||||||||||||||
| 297 | 257 | $$dwt =~ s{<!--\s*[Tt][Ee][Mm][Pp][Ll][Aa][Tt][Ee][Bb][Ee][Gg][Ii][Nn][Ii][Ff][Cc][Ll][Aa][Uu][Ss][Ee]\s+[Cc][Oo][Nn][Dd]\s*=\s*([\"\'])(.*?)\1\s*-->}{handleTemplateIf($2, $1, \%params, $using_template_expr )}esg; | |||||||||||||||||||||||||||||||
| 298 | 257 | $$dwt =~ s{<!--\s*[Tt][Ee][Mm][Pp][Ll][Aa][Tt][Ee][Ee][Nn][Dd][Ii][Ff][Cc][Ll][Aa][Uu][Ss][Ee]\s*-->}{<TMPL_ELSE>}sg; | |||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||
| 300 | 257 | ▶ | while ( $$dwt =~ m{(<!-- TemplateBeginMultipleIf -->(?:(?!<!-- Template(?:Begin|End)MultipleIf -->).)*<!-- TemplateEndMultipleIf -->)}s ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 301 | 1 | $$dwt =~ s{<!-- TemplateBeginMultipleIf -->(((?!<!-- Template(?:Begin|End)MultipleIf -->).)*)<!-- TemplateEndMultipleIf -->}{addEndifs($1)}se; | |||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||
| 304 | 257 | ▶ | while ( $$dwt =~ m{<TMPL_BEGIN_(?:IF|UNLESS)((?!</?TMPL_(?:BEGIN_IF|BEGIN_UNLESS|END_IF_UNLESS)).)*</TMPL_END_IF_UNLESS}s ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 305 | 34 | $$dwt =~ s{<TMPL_BEGIN_(IF|UNLESS)(((?!</?TMPL_(?:BEGIN_IF|BEGIN_UNLESS|END_IF_UNLESS)).)*)</TMPL_END_IF_UNLESS>} | |||||||||||||||||||||||||||||||
| 306 | 35 | ▶ | {"<TMPL_$1$2" . ( $1 eq "IF" ? "</TMPL_IF>" : "</TMPL_UNLESS>")}seg; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||
| 310 | 257 | $$dwt =~ s{<TMPL_(\w*) NAME=([\"\'])_isFirst\2}{<TMPL_$1 NAME=$2__FIRST__$2}sg; | |||||||||||||||||||||||||||||||
| 311 | 257 | $$dwt =~ s{<TMPL_(\w*) NAME=([\"\'])_isLast\2}{<TMPL_$1 NAME=$2__LAST__$2}sg; | |||||||||||||||||||||||||||||||
| 312 | 257 | $$dwt =~ s{<TMPL_(\w*) NAME=([\"\'])_index\2}{<TMPL_$1 NAME=$2__COUNTER__$2}sg; | |||||||||||||||||||||||||||||||
| 313 | 257 | $$dwt =~ s{<\!\-\- TMPL_(\w*) NAME=([\"\'])_isFirst\2}{<!-- TMPL_$1 NAME=$2__FIRST__$2}sg; | |||||||||||||||||||||||||||||||
| 314 | 257 | $$dwt =~ s{<\!\-\- TMPL_(\w*) NAME=([\"\'])_isLast\2}{<!-- TMPL_$1 NAME=$2__LAST__$2}sg; | |||||||||||||||||||||||||||||||
| 315 | 257 | $$dwt =~ s{<\!\-\- TMPL_(\w*) NAME=([\"\'])_index\2}{<!-- TMPL_$1 NAME=$2__COUNTER__$2}sg; | |||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||
| 317 | # TemplateBeginRepeat Name= | ||||||||||||||||||||||||||||||||
| 318 | 257 | $$dwt =~ s{<!--\s*[Tt][Ee][Mm][Pp][Ll][Aa][Tt][Ee][Bb][Ee][Gg][Ii][Nn][Rr][Ee][Pp][Ee][Aa][Tt]\s+[Nn][Aa][Mm][Ee]=([\"\'])(.*?)\1\s*-->}{<TMPL_LOOP NAME=$1$2$1>}sg; | |||||||||||||||||||||||||||||||
| 319 | # TemplateEndRepeat Name= | ||||||||||||||||||||||||||||||||
| 320 | 257 | $$dwt =~ s{<!--\s*[Tt][Ee][Mm][Pp][Ll][Aa][Tt][Ee][Ee][Nn][Dd][Rr][Ee][Pp][Ee][Aa][Tt]\s*-->}{</TMPL_LOOP>}sg; | |||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||
| 323 | 130 | ▶ | sub DWT2HTMLExpr { | ||||||||||||||||||||||||||||||
|
Subroutine
DWT2HTMLExpr: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 324 | 130 | DWT2HTML( shift, 1 ); | |||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||
| 328 | 1 | 1; | |||||||||||||||||||||||||||||||
| 329 | __END__ | ||||||||||||||||||||||||||||||||