-
-
11 Sep 2008 11:11:43 UTC
- Distribution: Template-Refine
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues
- Testers (94 / 341 / 1)
- Kwalitee
Bus factor: 2- % Coverage
- License: unknown
- Activity
24 month- Tools
- Download (18.68KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- unknown
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Template::Refine::Utils - sugar up some common
Template::Refine
operationsSYNOPSIS
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>
EXPORT
None by default. You can request
simple_replace
andreplace_text
. This module use Sub::Exporter, so you can rename the imports if you like.API STABILITY
I will probably add more utilities here in future releases.
FUNCTIONS
replace_text( $node, $text )
This makes a copy of
$node
and replaces the copied node's children with a text node containing$text
.As an example, if you pass in a node that looks like
<p>Hello, <b>world</b>.</p>
and the textFoo
, the result will be<p>Foo</p>
.simple_replace BLOCK $xpath
Generates a Template::Refine::Processor::Rule that selects nodes matching the
xpath
and transforms them with the provided BLOCK.This will save you a lot of typing.
SEE ALSO
Module Install Instructions
To install Template::Refine, copy and paste the appropriate command in to your terminal.
cpanm Template::Refine
perl -MCPAN -e shell install Template::Refine
For more information on module installation, please visit the detailed CPAN module installation guide.