-
Notifications
You must be signed in to change notification settings - Fork 9
Implement re-usable templates. #21
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
Conversation
* [`Template`]: borrows the source string. | ||
* [`TemplateBuf`]: owns the source string. | ||
* [`ByteTemplate`]: borrows the source bytes. | ||
* [`ByteTemplateBuf`]: owns the source bytes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to bikeshed over the naming.
} | ||
} | ||
|
||
/// Parse a braced variable in the form of "${name[:default]} from source at the given position. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add an example of this to the README?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm? That's an internal function. Nobody can call it directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just meant this syntax: ${name[:default]}
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah it's there already. I just can't read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right :)
This PR makes it possible to re-use a parsed template string more than once.
To preserve backwards compatibility the error types are a little but duplicate now, but I think it's worth it to avoid breaking compatibility.
This can also be used by #18 to implement the different expansion modes without breaking the API.