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

Retain Acronyms when casing #8

Open
TristanSpeakEasy opened this issue Jan 5, 2023 · 2 comments
Open

Retain Acronyms when casing #8

TristanSpeakEasy opened this issue Jan 5, 2023 · 2 comments
Assignees

Comments

@TristanSpeakEasy
Copy link

TristanSpeakEasy commented Jan 5, 2023

Hi, great library btw it has been very helpful with code gen work we are doing!

What did you do?

strcase.ToCamel("nativeOrgURL")

What did you expect to see?

output == "nativeOrgURL"

What did you see instead?

output == "nativeOrgUrl"

I was looking through the options of creating a custom caser and thought omitting the SplitAcronym option may have produced the output I would have expected.

But basically I would like to be able to pass a string and be able to retain any acronyms that are contained within without needing to understand the input and try and populate the initialisms map with any acronyms I want to retain (as the input comes from end-users so we could receive any acronym), I can't really use strcase.ToGoCamel as it initializes acronyms that weren't initially upper case ie nativeOrgUrl as we are generating code for languages other than Go.

Basically if

input = "nativeOrgURL" then output = "nativeOrgURL"
input = "nativeOrgUrl" then output = "nativeOrgUrl"

I don't see a way to achieve this at the moment with the library, any help figuring out if this is possible would be appreciated.

while it looks like I am just trying to have a noop in the case of the examples above we could receive inputs that are of any case for example native_org_url or NativeOrgURL and want to format to nativeOrgUrl or nativeOrlURL to produce properties names suitable for a typescript class for example

@liyanchang
Copy link
Collaborator

This is interesting and something worth considering. Trying to think through some of the performance and API implications before I rush something out. Thanks for the suggestion.

@liyanchang liyanchang self-assigned this Jan 13, 2023
@liyanchang liyanchang mentioned this issue Jan 14, 2023
2 tasks
@liyanchang
Copy link
Collaborator

liyanchang commented Jan 14, 2023

You can try #13 by doing go get github.com/ettle/strcase@liyanchang-preserve-initialism and let me know how that goes!

You will need to use a custom caser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants