From bcec979f1db58a5e1c0fe41d2b2453c9f6c61ad7 Mon Sep 17 00:00:00 2001 From: Guillaume Rousse <guillaume.rousse@renater.fr> Date: Tue, 24 Nov 2020 16:24:04 +0100 Subject: [PATCH] forgotten in #bf7b134 --- lib/AccountManager/Template/Plugin/Quote.pm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lib/AccountManager/Template/Plugin/Quote.pm diff --git a/lib/AccountManager/Template/Plugin/Quote.pm b/lib/AccountManager/Template/Plugin/Quote.pm new file mode 100644 index 0000000..73e35ee --- /dev/null +++ b/lib/AccountManager/Template/Plugin/Quote.pm @@ -0,0 +1,21 @@ +package AccountManager::Template::Plugin::Quote; + +use strict; +use warnings; +use Template::Stash; + +use constant DEFAULT_CHAR => '"'; + +$Template::Stash::SCALAR_OPS->{ quote } = sub { + my $scalar = shift; + my $char = shift || DEFAULT_CHAR; + return $char . $scalar . $char; +}; + +$Template::Stash::LIST_OPS->{ quote } = sub { + my $list = shift; + my $char = shift || DEFAULT_CHAR; + return [ map { $char . $_ . $char } @$list ]; +}; + +1; -- GitLab