(: Pass all requests to HTML files through view.xq, which handles HTML templating :)
if (ends-with($exist:resource, ".html")) then (
    <dispatch xmlns="http://exist.sourceforge.net/NS/exist">
        <view>
        <forward url="{$exist:controller}/modules/view.xq">
                <set-attribute name="$exist:prefix" value="{$exist:prefix}"/>
                <set-attribute name="$exist:controller" value="{$exist:controller}"/>
            </forward>
        </view>
        <error-handler>
            <forward url="{$exist:controller}/error-page.html" method="get"/>
            <forward url="{$exist:controller}/modules/view.xq"/>
        </error-handler>
    </dispatch>
) else (
    (: do something with all other requests :)
)
