On Monday, 2 November 2020 at 17:02:01 UTC, Steven Schveighoffer wrote:
On 11/2/20 10:10 AM, JG wrote:
I am trying to get the body the response generated by:

res.render!("index.dt");

where res is of type HTTPServerResponse

Does anyone know how I might go about this?


That is a convenience wrapper to diet-ng:

https://github.com/vibe-d/vibe.d/blob/70b50fdb9cd4144f1a5007b36e6ac39d4731c140/http/vibe/http/server.d#L337-L346

Instead, create your own output range (maybe a char[] appender?) and compile to that yourself:

import diet.html : compileHTMLDietFile;
import std.array : appdender;

auto app = appender!(char[]);
compileHTMLDietFile!("index.dt")(app);

auto resultingHTML = app.data;

-Steve

Thank you very much.

Reply via email to