question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Conversion to snake case should convert only case, not other characters

See original GitHub issue

Let’s have a string

\My\AppBundle\App\Twig\GoogleTagManagerDataLayer

I want to convert it to

my.app_bundle.app.twig.google_tag_manager_data_layer

That seems to be the exact case for string manipulation plugin. But it’s currently not possible. If I call “to snake_case” on it, it creates

my_app_bundle_app_twig_google_tag_manager_data_layer

I would expect the plugin to work on case (i.e. only convert [a-z][A-Z] to \1_\2) and not touch unknown characters. Current behaviour IMO severely limits use cases. What is this behvaiour’s use-case?

My other typical use case would be

Some\PHP\SubNamespace -> some/php/sub-namespace.twig (i.e. replace slashes + to hyphen-case)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
tomasfejfarcommented, Apr 24, 2017

Wow, thank you for speedy fix! ❤

1reaction
krasacommented, Apr 24, 2017

You asked "What is this behvaiour’s use-case? " 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

to_any_case: General case conversion in snakecase - Rdrr.io
Function to convert strings to any case. ... It should only be used in very rare use cases and is mainly implemented to...
Read more >
Convert Strings into any Case • snakecase
The snakecase package introduces a fresh and straightforward approach on case conversion, based upon a consistent design philosophy.
Read more >
Convert String to Different Case Styles ... - In Plain English
Snake case is the practice of writing compound words in which the words are separated by one underscore character and no spaces. The...
Read more >
snakecase: Convert Strings into any Case
Description A consistent, flexible and easy to use tool to parse and con- vert strings into cases like snake or camel among others....
Read more >
Snake case of a given sentence - GeeksforGeeks
Simple solution : First method is to traverse sentence and one by one replace spaces by underscores and changing case of first character...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found