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

toTitle function fails to understand word boundaries and unicode punctuation #1677

Closed
thevilledev opened this issue Dec 4, 2022 · 0 comments · Fixed by #1678
Closed

toTitle function fails to understand word boundaries and unicode punctuation #1677

thevilledev opened this issue Dec 4, 2022 · 0 comments · Fixed by #1678

Comments

@thevilledev
Copy link
Contributor

Consul Template version

consul-template v0.29.6 (e4f5d583)

Expected behavior

Consider the following template:

{{ "this isn't ok" | toTitle }}
{{ "foo\u2026bar" | toTitle }}

Expected output:

This Isn't Ok
Foo…Bar

Actual behavior

Template above yields the following:

This Isn'T Ok
Foo…bar

Title casing currently fails to understand word boundaries properly, leading to various issues with hyphenation and unicode punctuation.

References

Current implementation of toTitle function is based on strings.Title, which has been deprecated since Go 1.18. Instead, golang.org/x/text/cases should be used:

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