Skip to content

Add case conversion filters.#59

Merged
Keats merged 4 commits intoKeats:masterfrom
atholbro:add-tera-text-filters
Aug 1, 2023
Merged

Add case conversion filters.#59
Keats merged 4 commits intoKeats:masterfrom
atholbro:add-tera-text-filters

Conversation

@atholbro
Copy link
Copy Markdown
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
Copy Markdown
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

path: Option<PathBuf>,
) -> Result<String> {
let mut tera = Tera::default();
register_all(&mut tera);
Copy link
Copy Markdown
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
Copy Markdown
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 atholbro force-pushed the add-tera-text-filters branch from 8d97e9b to a2bb009 Compare July 5, 2022 18:43
@atholbro
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

Hey, any thoughts on merging this one?

@Keats
Copy link
Copy Markdown
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.

2 participants