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

Add case conversion filters. #59

Merged
merged 4 commits into from
Aug 1, 2023
Merged

Conversation

atholbro
Copy link
Contributor

@atholbro atholbro commented Jan 19, 2022

Hey,

Here's a quick little PR to add heck. This adds a few more text conversion options:

  • upper_camel_case
  • camel_case
  • snake_case
  • kebab_case
  • shouty_snake_case
  • title_case
  • shouty_kebab_case

Maybe required?

  • Perhaps a new example?
  • Maybe a unit test?

Copy link
Owner

@Keats Keats left a comment

Choose a reason for hiding this comment

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

It needs to be rebased.
Looking at the source of tera-text-filters, it's probably better for us to just depend on heck explicitely and add the few lines of glue without the extra dependency. We also don't need the docs for the filters in the source so thats literally maybe 15 LoC

@@ -67,6 +68,7 @@ impl Template {
path: Option<PathBuf>,
) -> Result<String> {
let mut tera = Tera::default();
register_all(&mut tera);
Copy link
Owner

Choose a reason for hiding this comment

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

Better to use tera_text_filters::register_all(&mut tera) and remove the import so it's clearer what happens

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ya I like this idea.

And I might take a look at depending on heck like you suggest.

@atholbro
Copy link
Contributor Author

atholbro commented Jul 5, 2022

Alright, it took me a while to get back to this but I've made the changes you've requested. The PR now depends on heck directly.

I put the filters in a new filters.rs file, happy to change the name or move them as I wasn't quite sure where you'd like these to live. I feel like there's probably a smarter way of defining these filter functions but I'm still new to rust so nothing really came to mind.

I also updated the README to include a bit about the additional filters.

@atholbro atholbro requested a review from Keats July 5, 2022 20:24
@atholbro atholbro changed the title Add tera-text-filters. Add case conversion filters. Jul 5, 2022
Copy link
Owner

@Keats Keats left a comment

Choose a reason for hiding this comment

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

Thanks!

@atholbro
Copy link
Contributor Author

Hey, any thoughts on merging this one?

@Keats
Copy link
Owner

Keats commented Jul 30, 2023

Woops sorry completely slipped my mind. I'll merge and do a release next week.

@Keats Keats merged commit 8c6aec3 into Keats:master Aug 1, 2023
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.

None yet

2 participants