| 1 | package DSL::HTML; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 7 | ▶ | use Carp qw/croak carp/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 7 | ▶ | use Scalar::Util qw/blessed/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 7 | ▶ | use Exporter::Declare::Magic qw{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | import | ||||||||||||||||||||||||||||||||||||||||||
| 10 | export | ||||||||||||||||||||||||||||||||||||||||||
| 11 | default_export | ||||||||||||||||||||||||||||||||||||||||||
| 12 | gen_export | ||||||||||||||||||||||||||||||||||||||||||
| 13 | gen_default_export | ||||||||||||||||||||||||||||||||||||||||||
| 14 | 7 | }; | |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 7 | ▶ | use DSL::HTML::Parser; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 7 | ▶ | use DSL::HTML::Template; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 7 | ▶ | use DSL::HTML::Rendering; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 7 | ▶ | use HTML::Element; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 7 | our $VERSION = '0.006'; | |||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 9 | ▶ | sub after_import { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
after_import: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 9 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 25 | 9 | my ( $importer, $specs ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 9 | inject_meta($importer); | |||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 12 | ▶ | sub inject_meta { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inject_meta: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 12 | my ($importer) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 12 | ▶ | return $importer->DSL_HTML | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | if $importer->can('DSL_HTML'); | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 10 | my $meta = {}; | |||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | { | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 7 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 10 | ▶ | *{"$importer\::DSL_HTML"} = sub { $meta }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 10 | return $meta; | |||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 7 | ▶ | default_export import { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=6 SCAR=18.6
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 3 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 3 | my $caller = caller; | |||||||||||||||||||||||||||||||||||||||||
| 50 | 3 | my $imeta = inject_meta($caller); | |||||||||||||||||||||||||||||||||||||||||
| 51 | 3 | my $meta = $class->DSL_HTML; | |||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 3 | ▶ | my @want = @_ ? @_ : keys %$meta; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 3 | for my $template (@want) { | |||||||||||||||||||||||||||||||||||||||||
| 56 | 8 | ▶ | if ( $imeta->{$template} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | carp "'$template' already defined in class '$caller', not replacing"; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 8 | ▶ | $imeta->{$template} = $meta->{$template} | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$meta->{$template} || carp("'${template}' is not defined by '${class}'")
MC/DC0%0/2
$meta->{$template} || carp("'${template}' is not defined by '${class}'")
$meta->{$template}
carp("'${template}' is not defined by '${class}'")
Truth table33%1/3
A || B
A= $meta->{$template}B= carp("'${template}' is not defined by '${class}'")
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | || carp "'$template' is not defined by '$class'"; | ||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 3 | ▶ | return 1 if $caller->can('build_template'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 7 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 1 | *{"$caller\::build_template"} = \&build_template; | |||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 71 | 7 | } | |||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | 7 | ▶ | default_export template dsl_html { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=4 SCAR=14.7
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 14 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 14 | ▶ | die "Template name is required" unless $name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 14 | my ( $params, $block ); | |||||||||||||||||||||||||||||||||||||||||
| 77 | 14 | ▶ | if ( @_ == 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 14 | $block = pop @_; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 14 | $params = {}; | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | $params = {@_}; | |||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | $block = delete $params->{block}; | |||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 14 | my $template = DSL::HTML::Template->new( $name, $params, $block ); | |||||||||||||||||||||||||||||||||||||||||
| 87 | 14 | ▶ | return $template if defined wantarray; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 14 | caller->DSL_HTML->{$name} = $template; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 7 | } | |||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 7 | ▶ | default_export tag dsl_html { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=10 SCAR=23.1
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 43 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||
| 94 | 43 | ▶ | croak "tag name is required" unless $name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 43 | my ( $params, $block ); | |||||||||||||||||||||||||||||||||||||||||
| 96 | 43 | ▶ | if ( @_ == 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 29 | $block = pop @_; | |||||||||||||||||||||||||||||||||||||||||
| 98 | 29 | $params = {}; | |||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||
| 100 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 14 | $params = {@_}; | |||||||||||||||||||||||||||||||||||||||||
| 102 | 14 | $block = delete $params->{block}; | |||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 43 | check_nesting('tag'); | |||||||||||||||||||||||||||||||||||||||||
| 106 | 43 | my $rendering = DSL::HTML::Rendering->current; | |||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 43 | my $tag; | |||||||||||||||||||||||||||||||||||||||||
| 109 | 43 | ▶ | if ( $name =~ m/^head$/i ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 4 | $tag = $rendering->head; | |||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | elsif ( $name =~ m/^body$/i ) { | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 2 | $tag = $rendering->body; | |||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||
| 115 | elsif ( $name =~ m/^html$/i ) { | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $tag = $rendering->root; | |||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 37 | $tag = HTML::Element->new( $name, %$params ); | |||||||||||||||||||||||||||||||||||||||||
| 120 | 37 | $rendering->insert($tag); | |||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 43 | $rendering->push_tag($tag); | |||||||||||||||||||||||||||||||||||||||||
| 124 | 43 | my @result; | |||||||||||||||||||||||||||||||||||||||||
| 125 | 43 | my $success = eval { | |||||||||||||||||||||||||||||||||||||||||
| 126 | 43 | @result = $block->($tag); | |||||||||||||||||||||||||||||||||||||||||
| 127 | 43 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 128 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 43 | my $error = $@; | |||||||||||||||||||||||||||||||||||||||||
| 130 | 43 | $rendering->pop_tag($tag); | |||||||||||||||||||||||||||||||||||||||||
| 131 | 43 | ▶ | die $error unless $success; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 43 | ▶ | $tag->push_content(@result) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
@result and not ref $result[0] and not $tag->content_list
@result and not ref $result[0]
MC/DC100%3/3
@result and not ref $result[0] and not $tag->content_list
@result
not ref $result[0]
not $tag->content_list
Truth table100%4/4
A and not(B) and not(C)
A= @resultB= not ref $result[0]C= not $tag->content_list
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | if @result && !ref $result[0] && !$tag->content_list; | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 43 | return; | |||||||||||||||||||||||||||||||||||||||||
| 137 | 7 | } | |||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 7 | ▶ | default_export get_template { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 2 | my $name = pop; | |||||||||||||||||||||||||||||||||||||||||
| 141 | 2 | ▶ | my $from = $_[0] || caller; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$_[0] || &CORE::GLOBAL::caller()
MC/DC0%0/2
$_[0] || &CORE::GLOBAL::caller()
$_[0]
&CORE::GLOBAL::caller()
Truth table66%2/3
A || B
A= $_[0]B= &CORE::GLOBAL::caller()
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 2 | return $from->DSL_HTML->{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 143 | 7 | } | |||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 7 | default_export 'build_template'; | |||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 4 | ▶ | sub build_template { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_template: called CC=4 SCAR=15.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 4 | my ( $template, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 149 | 4 | my $caller = caller; | |||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 4 | ▶ | $template->compile(@args) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($template) and $template->isa("DSL::HTML::Template")
MC/DC0%0/2
builtin::blessed($template) and $template->isa("DSL::HTML::Template")
builtin::blessed($template)
$template->isa("DSL::HTML::Template")
Truth table33%1/3
A and B
A= builtin::blessed($template)B= $template->isa("DSL::HTML::Template")
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | if blessed($template) | ||||||||||||||||||||||||||||||||||||||||||
| 153 | && $template->isa('DSL::HTML::Template'); | ||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | croak "No such template '$template'" | ||||||||||||||||||||||||||||||||||||||||||
| 156 | 4 | ▶ | unless $caller->DSL_HTML->{$template}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 4 | return $caller->DSL_HTML->{$template}->compile(@args); | |||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 7 | ▶ | default_export include { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 6 | my ( $template, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 6 | my $caller = caller; | |||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 6 | check_nesting('include'); | |||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | my $tmp = | ||||||||||||||||||||||||||||||||||||||||||
| 168 | blessed($template) | ||||||||||||||||||||||||||||||||||||||||||
| 169 | ? $template | ||||||||||||||||||||||||||||||||||||||||||
| 170 | 6 | ▶ | : $caller->DSL_HTML->{$template}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 6 | ▶ | croak "No such template '$template'" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | unless $tmp; | ||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 6 | DSL::HTML::Rendering->current->include( $tmp, @args ); | |||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 6 | return; | |||||||||||||||||||||||||||||||||||||||||
| 178 | 7 | } | |||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 7 | ▶ | default_export text { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 2 | my ($content) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 182 | 2 | check_nesting('text'); | |||||||||||||||||||||||||||||||||||||||||
| 183 | 2 | DSL::HTML::Rendering->current->peek_tag->push_content("$content"); | |||||||||||||||||||||||||||||||||||||||||
| 184 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||
| 185 | 7 | } | |||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 7 | ▶ | default_export css { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 8 | check_nesting('css'); | |||||||||||||||||||||||||||||||||||||||||
| 189 | 8 | DSL::HTML::Rendering->current->add_css(@_); | |||||||||||||||||||||||||||||||||||||||||
| 190 | 8 | return; | |||||||||||||||||||||||||||||||||||||||||
| 191 | 7 | } | |||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | 7 | ▶ | default_export js { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | 10 | check_nesting('js'); | |||||||||||||||||||||||||||||||||||||||||
| 195 | 10 | DSL::HTML::Rendering->current->add_js(@_); | |||||||||||||||||||||||||||||||||||||||||
| 196 | 10 | return; | |||||||||||||||||||||||||||||||||||||||||
| 197 | 7 | } | |||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 7 | ▶ | default_export attr { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 4 | check_nesting('attr'); | |||||||||||||||||||||||||||||||||||||||||
| 201 | 4 | my $tag = DSL::HTML::Rendering->current->peek_tag; | |||||||||||||||||||||||||||||||||||||||||
| 202 | 4 | ▶ | return unless @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 4 | ▶ | my $attrs = @_ < 2 ? shift : {@_}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | 4 | $tag->attr( $_ => $attrs->{$_} ) for keys %$attrs; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 4 | return; | |||||||||||||||||||||||||||||||||||||||||
| 206 | 7 | } | |||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | 7 | ▶ | default_export add_class { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 2 | check_nesting('add_class'); | |||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | 2 | my $tag = DSL::HTML::Rendering->current->peek_tag; | |||||||||||||||||||||||||||||||||||||||||
| 212 | 2 | ▶ | my $existing = $tag->attr('class') || ""; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$tag->attr('class') || ''
MC/DC0%0/1
$tag->attr('class') || ''
$tag->attr('class')
Truth table50%1/2
A
A= $tag->attr('class')
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 2 | my %seen; | |||||||||||||||||||||||||||||||||||||||||
| 215 | 2 | my $new = join " ", sort grep { !$seen{$_}++ } @_, split /\s+/, $existing; | |||||||||||||||||||||||||||||||||||||||||
| 216 | 2 | $tag->attr( class => $new ); | |||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||
| 219 | 7 | } | |||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 7 | ▶ | default_export del_class { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 2 | check_nesting('del_class'); | |||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | 2 | my $tag = DSL::HTML::Rendering->current->peek_tag; | |||||||||||||||||||||||||||||||||||||||||
| 225 | 2 | ▶ | my $existing = $tag->attr('class') || ""; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$tag->attr('class') || ''
MC/DC0%0/1
$tag->attr('class') || ''
$tag->attr('class')
Truth table50%1/2
A
A= $tag->attr('class')
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | 2 | my %seen = map { $_ => 1 } @_; | |||||||||||||||||||||||||||||||||||||||||
| 228 | 2 | my $new = join " ", sort grep { !$seen{$_}++ } split /\s+/, $existing; | |||||||||||||||||||||||||||||||||||||||||
| 229 | 2 | $tag->attr( class => $new ); | |||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||
| 232 | 7 | } | |||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 77 | ▶ | sub check_nesting { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_nesting: called CC=2 SCAR=8.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | 77 | my ($sub) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 236 | 77 | ▶ | return if DSL::HTML::Rendering->current; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | croak "No template stack found, '$sub()' must have been called outside of a template."; | |||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | __END__ | ||||||||||||||||||||||||||||||||||||||||||