Hello!
In my project I need to be able to change website theme on runtime, when user changes his preferences in profile.
I would like to stick to Diet engine.
For the time being I'm using something like that:
void renderT(string filename, ARGS...)()
{
string theme = "b2";
alias context = s_requestContext;
if (context.req.session && context.req.session["theme"] != "")
{
theme = context.req.session["theme"];
}
else
{
theme = context.req.fullURL().host != "dev.d3" ? "b2" : "orange";
}
final switch (theme)
{
case "b2": vibe.web.web.render!("b2/"~filename, ARGS)(); break;
case "orange": vibe.web.web.render!("orange/"~filename, ARGS)(); break;
}
}
and use it instead of render() method.
My application is based on vibe.web.web infrastructure.
The problem is that I need to keep my own copy of vibe.d in order to make srequestContext public field.
I am also not 100% sure if it is safe approach (using srequestContext).
Are there any other ways to achieve the same goal?
Maybe you are rolling your own solution and would like to share it with me? ;)
Best regards!