krzysztofzablocki / Sourcery

Meta-programming for Swift, stop writing boilerplate code.
http://merowing.info
MIT License
7.66k stars 616 forks source link

Converting variable names to lower_case_underscore style #163

Closed ggrell closed 7 years ago

ggrell commented 7 years ago

In our JSON structures, we generally name fields similarly to the JSON data field name counterparts. When generating JSON mapping code, it would be nice to be able to directly map from someFieldName to some_field_name. I see that Stencil has capitalize, uppercase & lowercase, and Sourcery additionally provides upperFirst (via what looks like a Stencil custom filter).

I'm interested in contributing a lowercaseUnderscore filter if that's something that people would find valuable.

krzysztofzablocki commented 7 years ago

We also use https://github.com/SwiftGen/StencilSwiftKit which has few other filters like snakeToCamelCase / snakeToCamelCaseNoPrefix, I think that might actually cover this already?

ggrell commented 7 years ago

Woah, I didn't know StencilSwiftKit had additional filters added to it! Looks like snakecase hasn't been exposed as a filter, happy to take care of it if needed.

krzysztofzablocki commented 7 years ago

sounds great, but we should do it on the StencilSwiftKit repo 👍