refactor(lib)!: create and expose a single Template object for users to interact with
#4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Having put a bit of thought into how to use this with television, I felt like this would be a more natural and intuitive interface for the lib.
The
Templatebecomes the god-object and is the only thing exposed to the end user which makes it clearer for the user - in my view - what's happening (withTemplate::parseandTemplate::formatbeing the only public entrypoints).This also enables hiding things such as
StringOpsetc. which I believe the user doesn't need to be aware of.Other nice thing is the user can now parse a template once and keep it lying around to format any number of strings (typically television's usecase).
Don't hesitate if anything's unclear,
Cheers,
And again, great work on the project!
PS: added a bit of documentation, feel free to update/remove that if you don't believe it's worth it.