1

Putting this here in case anyone finds it useful.

Strings like 'ABC thing' when pushed through camel and kebab filters can cause unexpected issues. For example…

{% set str = 'ABC thing' %}
{% set key = str|camel %}
{% set id  = key|kebab %}
{% set keyFromId = id|camel %}

{# 
  key       = 'aBCThing'
  id        = 'a-bc-thing'
  keyFromId = 'aBcThing'
#}

1 Answer 1

1

The solution is to invoke lower first:

{% set str = 'ABC thing' %}
{% set key = str|lower|camel %}
{% set id  = key|kebab %}
{% set keyFromId = id|camel %}

{# 
  key       = 'abcThing'
  id        = 'abc-thing'
  keyFromId = 'abcThing'
#}
1
  • 1
    Thanks for sharing this tip! If you could mark the solution as the "accepted answer" it'll close this topic out as resolved and allow others to browse it as a complete solution. It's totally valid to accept your own answer to a question :)
    – cherrykoda
    Commented Mar 16, 2023 at 20:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.