handlebars-rust
handlebars-rust copied to clipboard
Publish source api
This API would be useful for me, so I brought this branch up-to-date in #444.
@mkantor may I know your use case for this feature?
@mkantor may I know your use case for this feature?
My use case is to set up a registry from already-open File
s.
With handlebars-rust 3.x I'm using the old register_template_source
method which accepts any Read
. With the Source
API published in this PR I could create a impl Source for File
and use the new register_template_source
from this changeset. (...I'm now realizing this might not be precisely what I want, since I think I'd have to clone the File
in impl Source for File
. I guess my ideal API would be something closer to the old one where the source may be consumed/mutated. For my use case it's fine to give away ownership of the File
.)
If this doesn't get merged I'll probably use the path with register_template_file
and let handlebars-rust open a new File
, or maybe I'll just read the file contents to a String
and use register_template_string
, but I was kind of curious to try out dev mode.
I ended up using register_template_file
instead, which seems to be working nicely (https://github.com/mkantor/operator/pull/58). I don't think I have a strong use case for the source API after all.