NAME
XML::XSS::StyleAttribute - Style attribute for XML::XSS stylesheet rule
VERSION
version 0.3.5
SYNOPSIS
use XML::XSS;
my $xss = XML::XSS->new;
my $attribute = $xss->get('chapter')->pre;
$attribute->set_value( '<div class="chapter">' );
DESCRIPTION
The XML::XSS::StyleAttribute
objects are the building blocks of the document transformation. They can be assigned a string, which is inserted verbatim in the rendered document
$xss->get('chapter')->set_pre( '<div class="chapter">' );
or a sub reference, which return value is inserted in the rendered document
$xss->get('clock')->set_pre( sub { return "date and time are: " . localtime } );
Upon execution, the sub references will be passed three parameters: the invoking rule, the XML::LibXML::Node object currently rendered and the arguments ref given to render()
.
$xss->set( 'div' => {
intro => sub {
my ( $self, $node, $args ) = @_;
my @para = $node->findnodes( '@para' );
return "<p>node has " . @para . " para child nodes.</p>";
}
} );
OVERLOADING
*=
Assigns the right value to the attribue.
$xss.'chapter'.'pre' *= "<div class='chapter'>";
is equivalent to
$xss->set( chapter => { pre => "<div class='chapter'>" } );
x=
Similar to '*=', but considers the right side as a template and converts it via xsst
.
$xss.'chapter'.'pre' x= q{
<div class="chapter">
<% $r->stylesheet->stash{chapter_nbr}++ %>
};
is equivalent to
$xss->set( 'chapter' => { pre => xsst( <<'END_TEMPLATE' ) } );
<div class="chapter">
<% $r->stylesheet->stash{chapter_nbr}++ %>
END_TEMPLATE
ATTRIBUTES
value
The string or sub reference used by the style attribute.
# long way
$xss->get('chapter')->pre->set_value( '<div class="chapter">' );
# short way
$xss->set( chapter => { pre => '<div class="chapter">' } );
# shortest way
$xss.'chapter'.'pre' *= '<div class="chapter">';
AUTHOR
Yanick Champoux <yanick@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2017, 2013, 2011, 2010 by Yanick Champoux.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.