On Thu, 02 Mar 2017 07:09:20 GMT, infinityplusb wrote:

On Wed, 1 Mar 2017 18:28:43 +0100, Sönke Ludwig wrote:

The error message looks strange and from a first look I also couldn't
see where it went wrong.

Excellent! At least it's not something obvious, that makes me feel better. :D

Forgot to mention, server.d is the only place that is needed to change
I'll have a poke around and change everything in there then.

You can alternatively also define a @dietTraits struct
I have no idea what that is :P

Okay, turned out to be rather simple, although certainly not obvious. The function must be named filterShaderfs instead of filterShaderFS, or the filter invocation must be :filterFS instead of filterfs. I'll see what I can do to improve the error message.

Regarding the traits struct, it would look something like this:

@dietTaits struct CustomTraits {
    static string filterShaderfs(I)(I text)
    {
        return "<script id=\"shader-fs\" type=\"x-shader/x-fragment\">" ~ '\t' 
            ~ "precision mediump float;" ~ '\t' ~ "</script>";
    }
    static FilterCallback[string] filters;

    static this()
    {
        filters["shaderfs"] = (input, scope output) { output(filterShaderfs(input)); };
    }
}

void handleRequest(HTTPServerRequest req, HTTPServerResponse res)
{
    // Just pass it to any render() call and the filter will be available
    res.render!("test.dt", CustomTraits);
}