Name : perl-Template-Plugin-VMethods
| |
Version : 0.30.0
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : 1.4
| Date : 2011-10-10 07:41:01
|
Group : Unspecified
| Source RPM : perl-Template-Plugin-VMethods-0.30.0-1.4.src.rpm
|
Size : 0.01 MB
| |
Packager : (none)
| |
Summary : install vmethods
|
Description :
Simple base class to allow your module to install and remove virtual methods into the Template Toolkit.
All you need to do in your package is declare one or more of the variables AATTLIST_OPS, AATTSCALAR_OPS or AATTHASH_OPS to indicate what virtual methods you want to export.
These can either be the names of functions in your package, or name/subroutine reference pairs.
For example, using named functions:
package Template::Plugin::HexVMethod; use base qw(Template::Plugin::VMethods); AATTSCALAR_OPS = ( \"hex\" ); sub hex { sprintf \"%x\", $_[0] }; 1;
For example, using the name and subroutine ref pairs:
package Template::Plugin::DoubleVMethod; use base qw(Template::Plugin::VMethods); AATTSCALAR_OPS = ( double => \\&double_string); AATTLIST_OPS = ( double => \\&double_list); sub double_string { $_[0]x2 } sub double_list { [ (AATT{ $_[0] }) x 2] } 1;
For example, mixing the two freely:
package CaesarVMethod; use base qw(Template::Plugin::VMethods); AATTSCALAR_OPS = ( \"caesar\", \"rot13\" => sub { caesar($_[0],\"13\") } ); sub caesar { $string = shift; $string =~ tr/A-Za-z/B-ZAb-za/ for 1..$_[0]; return $string; }
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl/openSUSE_Tumbleweed/noarch |