Template::Refine::Fragment - represent and refine a fragment of HTML
use Template::Refine::Fragment; use Template::Refine::Processor::Rule; use Template::Refine::Processor::Rule::Select::XPath; use Template::Refine::Processor::Rule::Transform::Replace::WithText; my $frag = Template::Refine::Fragment->new_from_string( '<p>Hello, <span class="world"/>.' # invalid HTML ok ); my $refined = $frag->process( Template::Refine::Processor::Rule->new( selector => Template::Refine::Processor::Rule::Select::XPath->new( pattern => '//*[@class="world"]', ), transformer => Template::Refine::Processor::Rule::Transform::Replace::WithText->new( replacement => sub { return 'world'; }, ), ), ); return $refined->render; # "<p>Hello, <span class="world">world</span>.</p>"
Accepts one argument, fragment, which is the XML::LibXML::DocumentFragment that you want to operate on.
The constructors below are more useful.
Accepts an XML::LibXML::DOM object
Accepts an HTML string
Accepts a filename containing HTML
Return the XML::LibXML::DocumentFragment that backs this object.
XML::LibXML::DocumentFragment
Apply Template::Refine::Processor::Rules in @rules and return a new Template::Refine::Fragment.
Template::Refine::Processor::Rule
@rules
Template::Refine::Fragment
Return the fragment as valid HTML
Report to RT.
You can browse the repository at:
http://git.jrock.us/?p=Template-Refine.git;a=summary
You can clone the repository by typing:
git clone git://git.jrock.us/Template-Refine
Please e-mail me any patches. Thanks in advance for your help!
Jonathan Rockway <jrockway@cpan.org>
<jrockway@cpan.org>
Copyright (c) 2008 Infinity Interactive. All rights reserved This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
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.