Skip to content

Implement re-usable templates. - #21

Merged
de-vri-es merged 1 commit into
mainfrom
template
Jun 25, 2024
Merged

Implement re-usable templates.#21
de-vri-es merged 1 commit into
mainfrom
template

Conversation

@de-vri-es

Copy link
Copy Markdown
Contributor

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.

Comment thread README.md
Comment on lines +23 to +26
* [`Template`]: borrows the source string.
* [`TemplateBuf`]: owns the source string.
* [`ByteTemplate`]: borrows the source bytes.
* [`ByteTemplateBuf`]: owns the source bytes.

Copy link
Copy Markdown
Contributor Author

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.

Comment thread src/template/raw/parse.rs
}
}

/// Parse a braced variable in the form of "${name[:default]} from source at the given position.

Copy link
Copy Markdown

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?

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown

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]}.

Copy link
Copy Markdown

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah, right :)

@de-vri-es
de-vri-es merged commit 5a3c5a2 into main Jun 25, 2024
@de-vri-es
de-vri-es deleted the template branch June 25, 2024 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants