Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish source api #415

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Publish source api #415

wants to merge 8 commits into from

Conversation

sunng87
Copy link
Owner

@sunng87 sunng87 commented Feb 16, 2021

No description provided.

@sunng87 sunng87 force-pushed the master branch 2 times, most recently from 7abfce6 to 4962d7e Compare June 4, 2021 16:55
@mkantor
Copy link
Contributor

mkantor commented Jun 7, 2021

This API would be useful for me, so I brought this branch up-to-date in #444.

@sunng87 sunng87 closed this Jun 7, 2021
@sunng87 sunng87 reopened this Jun 7, 2021
Merge master and add a test for `register_template_source`
pub fn get_templates(&self) -> &HashMap<String, Template> {
&self.templates
/// Return all registered template names
pub fn get_template_names(&self) -> Vec<String> {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sad that we didn't catch the 4.0 release train to ship this break change.

With the Source API, the original get_templates() -> &HashMap<String, Template> has lost its meaning

@sunng87
Copy link
Owner Author

sunng87 commented Jun 7, 2021

@mkantor may I know your use case for this feature?

@mkantor
Copy link
Contributor

mkantor commented Jun 9, 2021

@mkantor may I know your use case for this feature?

My use case is to set up a registry from already-open Files.

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.

@mkantor
Copy link
Contributor

mkantor commented Jun 13, 2021

I ended up using register_template_file instead, which seems to be working nicely (mkantor/operator#58). I don't think I have a strong use case for the source API after all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants