Currently I'm using Vibe.d to make a website, which has a Response
class that's handed to every request. That looks something like this:
import vibe.d;
void index(HTTPServerRequest req, HTTPServerResponse res)
{
res.render!("index.dt", req);
}
shared static this()
{
auto router = new URLRouter;
router.get("/", &index);
auto settings = new HTTPServerSettings;
settings.port = 8080;
listenHTTP(settings, router);
}
In the example, I'm passing a const string
"index.dt
to the res.render!
method, but I want to pass a variable:
void render(string action, HTTPServerResponse res) {
res.render!(action);
}
But I get the following error:
Error: variable action cannot be read at compile time
In every spot I'm calling render
, I've hardcoded strings:
render("foo.dt");
But that doesn't satisfy the compiler. Any idea how I can make this work?