TT#74153 add utils Template::Plugin

"Utils" TT plugin, to be extended.
provides base64 encoding for now, used by
provisioningtemplates feature.

Change-Id: I2980b57e5dae3d2595ba7017efcdc7e0bd00e469
changes/39/36839/3
Rene Krenn 6 years ago committed by Guillem Jover
parent 5c1e24ea16
commit bfd9be075e

@ -25,6 +25,7 @@ sub new
ABSOLUTE => 1,
RELATIVE => 1,
EVAL_PERL => 1,
PLUGIN_BASE => 'NGCP::Template::Plugin',
%{$config},
});

@ -0,0 +1,73 @@
package NGCP::Template::Plugin::Utils 1.000;
use strict;
use warnings;
use parent qw(Template::Plugin);
use MIME::Base64 ();
sub new {
my ($class, $context, @params) = @_;
bless {
_CONTEXT => $context,
}, $class;
}
sub encode_base64 {
my ($self, @params) = @_;
return MIME::Base64::encode($params[0], '');
}
1;
__END__
=encoding UTF-8
=head1 NAME
NGCP::Template::Plugin::Utils - Utils plugin
=head1 VERSION
Version 1.000
=head1 DESCRIPTION
This module provides common, stateless utility methods for NGCP templates
using Template::Plugin mechanism.
[% USE Utils %]
=head1 METHODS
=over 8
=item [% encoded = Utils.encode_base64(unencoded) %]
Converts give input String to base64.
=back
=head1 AUTHOR
Rene Krenn, C<< <rkrenn@sipwise.com> >>
=head1 LICENSE
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
=cut
Loading…
Cancel
Save