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;
my $dir_tmpl  = $html->dir_html;

DESCRIPTION

This module provides HTML template strings used to render a directory index page. The actual rendering is performed by WebServer::DirIndex.

METHODS

file_html

Returns a sprintf format string used to render a single file row (without an icon column). Contains 5 %s placeholders.

file_html_icons

Returns a sprintf format string used to render a single file row with a Font Awesome icon in the first column. Contains 6 %s placeholders.

dir_html

Returns a sprintf format string used to render the full directory index page (without icons).

dir_html_icons

Returns a sprintf format string used to render the full directory index page with a Font Awesome CDN link and an icon column header.

SUBCLASSING

You can subclass this module to provide custom HTML templates. Override file_html and/or dir_html in your subclass by declaring new fields with the :reader attribute.

All templates are sprintf format strings. The placeholders (%s) are positional and must be preserved in the correct order:

file_html placeholders (5 total, in order)

url, name, size, mime_type, mtime.

file_html_icons placeholders (6 total, in order)

icon_class, url, name, size, mime_type, mtime.

dir_html placeholders (4 total, in order)

Page title, inline css, page heading, file rows.

dir_html_icons placeholders (4 total, in order)

Page title, inline css, page heading, file rows.

Pass your subclass name as the html_class parameter when constructing WebServer::DirIndex or WebServer::DirIndex::File.

When icons is enabled in WebServer::DirIndex, the file_html_icons and dir_html_icons templates are used instead of file_html and dir_html, provided the html class supports them (detected via can).

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.

SEE ALSO

WebServer::DirIndex
WebServer::DirIndex::CSS
Plack::App::DirectoryIndex