lambda-fairy / maud

:pencil: Compile-time HTML templates for Rust
https://maud.lambda.xyz
Apache License 2.0
2.09k stars 137 forks source link

Feature: Hot-reload / Runtime interpretor for debug mode #392

Closed wrapperup closed 11 months ago

wrapperup commented 1 year ago

Love the library, it's really nice!

This would add an optional feature that allows maud to embed a runtime parser/interpreter that can read its own macro block from Rust source code. This runtime templating is limited in scope, meaning that changes to data, bindings, etc will require a recompile, but other changes could be done by interpreting the macro block at runtime (which IMO covers a lot of iteration time). This is definitely a bigger task with multiple steps, but I think it can be a really useful feature.

This is something Dioxus has implemented as a CLI tool, and I made a proof-of-concept implementation html_hotreload! (renamed to html! in the video) macro that uses maud's parser to generate a runtime instead that also parses itself at runtime (inception...).

https://github.com/lambda-fairy/maud/assets/7478134/274f2fcd-99e2-4cc2-899d-925d07f08263

Is this something you'd be interested in including with maud as an optional feature, or is it out of scope for maud? I think it could be it's own crate with a small refactor to expose maud's proc-macro/parser internals.

Either way, thanks for the useful library!

lambda-fairy commented 11 months ago

Hi @wrapperup, thanks for sharing! That looks really cool.

I think I'm too busy right now to review major changes like this. Feel free to iterate out-of-tree!