Template::Refine::Utils - sugar up some common Template::Refine operations
Template::Refine
use Template::Refine::Fragment; use Template::Refine::Utils qw(simple_replace replace_text); my $f = Template::Refine::Fragment->new_from_string('<p>Hello</p>'); say $f->process( simple_replace { my $n = shift; replace_text $n, 'Goodbye' } '//p', )->render; # prints <p>Goodbye</p>
None by default. You can request simple_replace and replace_text. This module use Sub::Exporter, so you can rename the imports if you like.
simple_replace
replace_text
I will probably add more utilities here in future releases.
This makes a copy of $node and replaces the copied node's children with a text node containing $text.
$node
$text
As an example, if you pass in a node that looks like <p>Hello, <b>world</b>.</p> and the text Foo, the result will be <p>Foo</p>.
<p>Hello, <b>world</b>.</p>
Foo
<p>Foo</p>
Generates a Template::Refine::Processor::Rule that selects nodes matching the xpath and transforms them with the provided BLOCK.
xpath
This will save you a lot of typing.
Template::Refine::Fragment
XML::LibXML
XML::LibXML::Node
XML::LibXML::Element
XML::LibXML::Text
To install Template::Refine, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Template::Refine
CPAN shell
perl -MCPAN -e shell install Template::Refine
For more information on module installation, please visit the detailed CPAN module installation guide.