plopjs / plop

Consistency Made Simple
http://plopjs.com
MIT License
7.06k stars 277 forks source link

titleCase fails to transform name #415

Open viveleroi opened 7 months ago

viveleroi commented 7 months ago

I have a line of code in an hbs helper:

<WindowHeader onClose={onClose} title='{{titleCase name}}' />

When I run a plop command and name is set to someName, all of the kebab and pascal casing conversions work fine, but the titleCase one does nothing.

The output is:

<WindowHeader onClose={onClose} title='someName' />

Am I missing something or doing something wrong? The handlebars braces are being read just fine as it's replacing the template with the value, it's just not converting the value to title case

tidemann commented 7 months ago

I'm also having issues with titleCase. Did a quick test with variable name set to "test-foo-bar": {{name}} {{pascalCase name}} {{titleCase name}} outputs: test-foo-bar TestFooBar Test-Foo-Bar I would expect {{titleCase name}} to output: "Test Foo Bar"

ricardo85x commented 1 month ago

I encountered the same issue with version 0.32.0.

As an alternative, I'm using the sentenceCase function, which produces a similar result.

For example, hello_world becomes Hello world, but the ideal result would be Hello World.