| 1 | package XML::XSS::Element; | ||||||||||||||||||||||||||||||||
| 2 | 15 | our $AUTHORITY = 'cpan:YANICK'; | |||||||||||||||||||||||||||||||
| 3 | # ABSTRACT: XML::XSS element stylesheet rule | ||||||||||||||||||||||||||||||||
| 4 | 15 | $XML::XSS::Element::VERSION = '0.3.5'; | |||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||
| 6 | 15 | ▶ | use Moose; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | 15 | ▶ | use MooseX::SemiAffordanceAccessor; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | 15 | ▶ | use MooseX::Clone; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | 15 | ▶ | use Scalar::Util qw/ refaddr /; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | 15 | with 'XML::XSS::Role::Renderer', 'MooseX::Clone'; | |||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||
| 14 | 15 | ▶ | no warnings qw/ uninitialized /; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | 30 | ▶ | sub render_attributes { | ||||||||||||||||||||||||||||||
|
Subroutine
render_attributes: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 18 | 30 | return qw/ process content showtag rename pre intro | |||||||||||||||||||||||||||||||
| 19 | prechildren prechild postchild postchildren extro post /; | ||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | 15 | has [ render_attributes() ] => ( traits => [qw/ XML::XSS::Role::StyleAttribute Clone /] ); | |||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||
| 24 | 72 | ▶ | before "set_$_" => sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 25 | 72 | my $self = shift; | |||||||||||||||||||||||||||||||
| 26 | 72 | ▶ | $self->detach_from_stylesheet if $self->_within_apply; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||
| 28 | 15 | for render_attributes(); | |||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||
| 31 | 94 | ▶ | sub apply { | ||||||||||||||||||||||||||||||
|
Subroutine
apply: called CC=13 SCAR=25.7
| |||||||||||||||||||||||||||||||||
| 32 | 94 | my ( $self, $node, $args ) = @_; | |||||||||||||||||||||||||||||||
| 33 | 94 | ▶ | $args ||= {}; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$args ||= {}
MC/DC0%0/1
$args ||= {}
$args
Truth table50%1/2
A
A= $args
| |||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||
| 35 | return | ||||||||||||||||||||||||||||||||
| 36 | 94 | ▶ | if $self->has_process and !$self->_render( 'process', $node, $args ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->has_process and not $self->_render("process", $node, $args)
MC/DC100%2/2
$self->has_process and not $self->_render("process", $node, $args)
$self->has_process
not $self->_render("process", $node, $args)
Truth table100%3/3
A and not(B)
A= $self->has_processB= not $self->_render("process", $node, $args)
| |||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | 93 | my $output = $self->_render( 'pre', $node, $args ); | |||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||
| 40 | 93 | ▶ | my $showtag = | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$self->has_pre or $self->has_content
MC/DC100%2/2
$self->has_pre or $self->has_content
$self->has_pre
$self->has_content
Truth table100%3/3
A or B
A= $self->has_preB= $self->has_content
| |||||||||||||||||||||||||||||||||
| 41 | $self->has_showtag ? $self->showtag | ||||||||||||||||||||||||||||||||
| 42 | : $self->has_pre || $self->has_content ? 0 : 1; | ||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||
| 44 | 93 | my $name; | |||||||||||||||||||||||||||||||
| 45 | 93 | ▶ | if ($showtag) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 46 | 66 | ▶ | $name = | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 47 | $self->has_rename | ||||||||||||||||||||||||||||||||
| 48 | ? $self->_render( 'rename', $node, $args ) | ||||||||||||||||||||||||||||||||
| 49 | : $node->nodeName; | ||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||
| 51 | $output .= join ' ', | ||||||||||||||||||||||||||||||||
| 52 | "<$name", | ||||||||||||||||||||||||||||||||
| 53 | 0 | map { join '=', $_->nodeName, "'@{[$_->serializeContent]}'" } | |||||||||||||||||||||||||||||||
| 54 | $node->attributes; | ||||||||||||||||||||||||||||||||
| 55 | 66 | $output .= '>'; | |||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||
| 58 | 93 | $output .= $self->_render( 'intro', $node, $args ); | |||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||
| 60 | 93 | ▶ | if ( $self->has_content ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 61 | 18 | $output .= $self->_render( 'content', $node, $args ); | |||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||
| 63 | else { | ||||||||||||||||||||||||||||||||
| 64 | 75 | ▶ | if ( my @children = $node->childNodes ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 65 | 57 | $output .= $self->_render( 'prechildren', $node, $args ); | |||||||||||||||||||||||||||||||
| 66 | 57 | for ( $node->childNodes ) { | |||||||||||||||||||||||||||||||
| 67 | 83 | $output .= $self->_render( 'prechild', $node, $args ); | |||||||||||||||||||||||||||||||
| 68 | 83 | $output .= $self->render( $_, $args ); | |||||||||||||||||||||||||||||||
| 69 | 83 | $output .= $self->_render( 'postchild', $node, $args ); | |||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||
| 71 | 57 | $output .= $self->_render( 'postchildren', $node, $args ); | |||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||
| 75 | 93 | $output .= $self->_render( 'extro', $node, $args ); | |||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||
| 77 | 93 | ▶ | $output .= "</$name>" if $showtag; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||
| 79 | 93 | $output .= $self->_render( 'post', $node, $args ); | |||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||
| 81 | 93 | return $output; | |||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||
| 84 | 15 | 1; | |||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||
| 86 | __END__ | ||||||||||||||||||||||||||||||||