rejectedsoftware / diet-ng

Compile-time indentation based, XML structured template system
MIT License
44 stars 24 forks source link

added runtime "static templates" fix #16 #56

Open WebFreak001 opened 6 years ago

WebFreak001 commented 6 years ago

Ironically the runtime filters don't work at runtime yet.

s-ludwig commented 5 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.

WebFreak001 commented 5 years ago

Great idea! What would be even cooler is a callback function for embedded code so you can for example embed lua or js

schveiguy commented 4 years ago

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