serveTemplateDirectory

Serves up a directory of template files as html. This is meant to be used for some near-static html in the midst of an application, giving you a little bit of dynamic content and conveniences with the ease of editing files without recompiles.

serveTemplateDirectory
(
alias wtrFactory = DefaultWtrFactory
)
(
string urlPrefix
,
string directory = null
,
string skeleton = null
,
string extension = ".html"
,
string templateDirectory = "templates/"
)

Parameters

urlPrefix string

the url prefix to trigger this handler, relative to the current dispatcher base

directory string

the directory, under the template directory, to find the template files

skeleton string

the name of the skeleton file inside the template directory

extension string

the file extension to add to the url name to get the template name

wtrFactory

an alias to a function of type WebTemplateRenderer function(TemplateLoader loader) that returns new WebTemplateRenderer(loader) (or similar subclasses/argument lists);

To get the filename of the template from the url, it will:

1) Strip the url prefixes off to get just the filename

2) Concatenate the directory with the template directory

3) Add the extension to the givenname

The templateDirectory parameter may be removed or changed in the near future.

Meta

History

Added July 28, 2021 (documented dub v11.0)

The wtrFactory parameter was added on February 5, 2024 (dub v11.5).