Request scoped information in Vibe.d

Johannes Loher johannes.loher at fg4f.de
Sun Jul 22 08:43:23 UTC 2018


On Sunday, 22 July 2018 at 06:21:40 UTC, Venkat wrote:
> How do I make variables available to diet templates ? Java has 
> request.setAttribute. Vibe.d's HTTPServerRequest has params and 
> queryString. But by the looks of it, neither one of them is 
> created for the purpose of temporary storage in the request. 
> Where do I store request scoped information ?

What is your usecase? If you simply want to pass a variable to a 
diet template, just pass it as a template parameter to render:

/* ... */

int myVar = 42;
render!("mytemplate.dt", myVar);

/* ... */

Then in mytemplate.dt, you can do something like:

p The best number ever is #{ myVar }


More information about the Digitalmars-d-learn mailing list