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.

dir_html

Returns a sprintf format string used to render the full directory index page.

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.

Both 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.

dir_html 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.

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