Open SingingBush opened 8 years ago
I'm using the WebInterface and have the following struct as a session var:
struct CurrentUser { string username = null; bool authenticated = false; bool administrator = false; }
available to the class as SessionVar!(CurrentUser, "user") currentUser;
SessionVar!(CurrentUser, "user") currentUser;
I'm currently getting the values off it and passing them on to the diet templates like this:
@method(HTTPMethod.GET) void index() { CurrentUser cUser = currentUser; render!("mytemplate.dt", cUser); }
but that's horrible and can get really messy later when there's more going on. I'd like to just do:
@method(HTTPMethod.GET) void index() { render!("mytemplate.dt"); }
and have currentUser available to all my diet templates by some kind of global config, so my methods can focus on the data that is specific to them. is that possible?
currentUser
I've been looking at vibe.templ.utils as it seems that the injector stuff maybe what I'm after. I'm not quite sure how to implement it yet though.
vibe.templ.utils
I'm using the WebInterface and have the following struct as a session var:
available to the class as
SessionVar!(CurrentUser, "user") currentUser;
I'm currently getting the values off it and passing them on to the diet templates like this:
but that's horrible and can get really messy later when there's more going on. I'd like to just do:
and have
currentUser
available to all my diet templates by some kind of global config, so my methods can focus on the data that is specific to them. is that possible?