Name : perl-Template-Plugin-Subst
| |
Version : 0.02
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : 6.71
| Date : 2024-08-05 20:19:11
|
Group : Development/Libraries/Perl
| Source RPM : perl-Template-Plugin-Subst-0.02-6.71.src.rpm
|
Size : 0.01 MB
| |
Packager : (none)
| |
Summary : s/// functionality for Template Toolkit templates
|
Description :
Template::Plugin::Subst acts as a filter and a virtual method to carry out regular expression substitutions with back references on text and variables in the Template Toolkit.
That\'s the advantage of this approach over the built-in \'replace\' method. \'replace\' doesn\'t deal with backrefs, so code like this:
[% str = \'foobar\' %] [% str.replace(\'(foo)(bar)\', \'$2$1\') %]
inserts a literal \'$2$1\' in to your document.
But with Template::Plugin::Subst;
[% USE Subst %] [% str = \'foobar\' %] [% str.subst(\'(foo)(bar)\', \'$2$1\') %]
you get the expected \'barfoo\'.
It can also be used as a filter, in which case it\'s very useful for finding information in text and augmenting it in a useful fashion.
For example, suppose you want all strings of the form \'rt#\\d+\', which reference RT ticket numbers, to be converted to links to your local RT installation.
First, instatiate the filter:
[% USE rt = Subst pattern = \'rt#(\\d+)\' replacement = \'< a href=\"/rt.cgi?t=$1\">rt#$1< /a>\' %]
and then use it to filter arbitrary text:
[% text_variable | $rt %]
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl:/CPAN-T/openSUSE_Tumbleweed/noarch |