Open WebFreak001 opened 6 years ago
Looks good as far as I can see. The only real question to me is in which direction this could be extended and consequently how the API should be layed out. What I'm currently thinking is something like this:
enum RuntimeRenderMode {
static_, /// Allows only static contents, any embedded code will trigger an exception
debug_, /// Embeds D code into the output without executing them
dynamic /// Builds the template as a shared library by invoking the compiler and executes the generated code
}
void renderRuntimeHTMLDiet(..., RuntimeRenderMode.static_);
The second option could even output in a format that is compatible with a plain-text template engine like Mustache or similar (or that could be left for another mode). Of course for now there would just be the static_
option.
Great idea! What would be even cooler is a callback function for embedded code so you can for example embed lua or js
I just submitted a PR for a new type of diet parsing I called "Live Mode" which outputs HTML data that it rereads from the view file at runtime. I had to do quite a bit of the same things you did here. It does support embedded D code, but only if the code hasn't changed structure at all. See the result here: #70
Ironically the runtime filters don't work at runtime yet.