NAME
WebServer::DirIndex::HTML - HTML rendering for directory index pages
SYNOPSIS
use WebServer::DirIndex::HTML;
my $html = WebServer::DirIndex::HTML->new;
my $file_tmpl = $html->file_html; # non-icon template
my $dir_tmpl = $html->dir_html;
my $html_icons = WebServer::DirIndex::HTML->new(icons => 1);
my $file_tmpl_icons = $html_icons->file_html; # icon template
my $dir_tmpl_icons = $html_icons->dir_html;
DESCRIPTION
This module provides HTML template strings used to render a directory index page. The actual rendering is performed by WebServer::DirIndex.
CONSTRUCTOR
- new(%args)
-
Creates a new
WebServer::DirIndex::HTMLobject. Accepts the following optional named parameter:- icons
-
If true,
file_htmlanddir_htmlreturn icon-aware templates (with a Font Awesome icon column). Defaults to false.
METHODS
- file_html
-
Returns a
sprintfformat string used to render a single file row. Wheniconsis true, returns the icon-aware template (6%splaceholders:icon_class,url,name,size,mime_type,mtime). Otherwise returns the standard template (5%splaceholders:url,name,size,mime_type,mtime). - dir_html
-
Returns a
sprintfformat string used to render the full directory index page. Wheniconsis true, returns the icon-aware template (with Font Awesome CDN link and icon column header). Otherwise returns the standard template. Both variants have 4%splaceholders: pagetitle, inlinecss, pageheading,file rows. - file_html_icons
-
Returns the icon-aware
sprintfformat string for a single file row, regardless of theiconsfield. Contains 6%splaceholders:icon_class,url,name,size,mime_type,mtime. - dir_html_icons
-
Returns the icon-aware
sprintfformat string for the full directory index page, regardless of theiconsfield. Includes a Font Awesome CDN link and icon column header. Contains 4%splaceholders: pagetitle, inlinecss, pageheading,file rows.
SUBCLASSING
You can subclass this module to provide custom HTML templates. Override file_html and/or dir_html by declaring new fields with the :reader attribute in your subclass.
Pass your subclass name as the html_class parameter when constructing WebServer::DirIndex or WebServer::DirIndex::File. The icons parameter is passed to the constructor automatically.
AUTHOR
Dave Cross <dave@perlhacks.com>
COPYRIGHT
Copyright (c) 2026 Magnum Solutions Limited. All rights reserved.
LICENCE
This code is free software; you can redistribute it and/or modify it under the same terms as Perl itself.