From 8470024657a9516ae4f50c4cb75f59f16056824a Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Thu, 12 Apr 2018 11:21:05 +0200 Subject: [PATCH] Bug 20538: Add POD for Asset.pm Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- Koha/Template/Plugin/Asset.pm | 65 +++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/Koha/Template/Plugin/Asset.pm b/Koha/Template/Plugin/Asset.pm index 59b6c85086..5b78345174 100644 --- a/Koha/Template/Plugin/Asset.pm +++ b/Koha/Template/Plugin/Asset.pm @@ -17,6 +17,29 @@ package Koha::Template::Plugin::Asset; # You should have received a copy of the GNU General Public License # along with Koha; if not, see . +=head1 NAME + +Koha::Template::Plugin::Asset + +=head1 DESCRIPTION + +The Asset plugin is a helper that generates HTML tags for JS and CSS files + +=head1 SYNOPSYS + + [% USE Asset %] + + [% Asset.css("css/datatables.css") %] + [% Asset.js("js/datatables.js") %] + + [%# With attributes %] + [% Asset.css("css/print.css", { media = "print" }) %] + + [%# If you only want the url and not the HTML tag %] + [% url = Asset.url("css/datatables.css") %] + +=cut + use Modern::Perl; use Template::Plugin; @@ -26,6 +49,14 @@ use File::Basename; use File::Spec; use C4::Context; +=head1 FUNCTIONS + +=head2 new + +Constructor. Do not use this directly. + +=cut + sub new { my ($class, $context) = @_; @@ -36,6 +67,14 @@ sub new { return bless $self, $class; } +=head2 js + +Returns a '; } +=head2 css + +Returns a tag for the given CSS file + + [% Asset.css('css/datatables.css') %] + [% Asset.css('css/print.css', { media = "print" }) %] + +=cut + sub css { my ( $self, $filename, $attributes ) = @_; @@ -66,6 +114,14 @@ sub css { return $self->tag('link', $attributes); } +=head2 url + +Returns the URL for the given file + + [% Asset.url('css/datatables.css') %] + +=cut + sub url { my ( $self, $filename ) = @_; @@ -93,6 +149,15 @@ sub url { } } +=head2 tag + +Returns an HTML tag with given name and attributes. +This shouldn't be used directly. + + [% Asset.tag("script", { src = "/koha-tmpl/intranet-tmpl/prog/css/datatables.css" }) %] + +=cut + sub tag { my ($self, $name, $attributes) = @_; -- 2.39.5