nickel-org / rust-mustache

mustache template library for rust
Other
204 stars 62 forks source link

Implementing a generic method to get content the partials #67

Open ayourtch opened 4 years ago

ayourtch commented 4 years ago

For my project (https://github.com/ayourtch/rsp10) I would like to embed into the framework code the default formatting of the html elements, which implies that any partial under html/* would need to be loaded from within the framework rather than the file on disk..

Is that something that you might consider interesting to merge ? If no - then please discard the rest of this text :-)

If yes:

In particular, I plan to refactor out this bit: https://github.com/nickel-org/rust-mustache/blob/master/src/compiler.rs#L66..L90 Into something more pluggable.

One option seems to make a PartialsMap a trait, and abstract both the HashMap and the code to supply the text of the partials in there..

Another option is to allow to specify a closure Fn(&str)->Result, which would be called first and return Err to trigger the current behavior of loading from files...

Is either of these two acceptable ? Or there is some other approach ?

Thanks!