<p>The solution is to invoke <code>lower</code> first:</p>
<pre><code>{% set str = 'ABC thing' %}
{% set key = str|lower|camel %}
{% set id  = key|kebab %}
{% set keyFromId = id|camel %}

{# 
  key       = 'abcThing'
  id        = 'abc-thing'
  keyFromId = 'abcThing'
#}
</code></pre>

CC BY-SA 4.0
2023-03-16T20:18:55.273Z
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
CC BY-SA 4.0
2023-03-02T15:55:03.647Z
2023-03-02T15:55:03.647Z
Jonathan Schofield
<p>Putting this here in case anyone finds it useful.</p>
<p>Strings like 'ABC thing' when pushed through <code>camel</code> and <code>kebab</code> filters can cause unexpected issues. For example…</p>
<pre><code>{% set str = 'ABC thing' %}
{% set key = str|camel %}
{% set id  = key|kebab %}
{% set keyFromId = id|camel %}

{# 
  key       = 'aBCThing'
  id        = 'a-bc-thing'
  keyFromId = 'aBcThing'
#}
</code></pre>

<filter><string>
How to control string translation through camel to kebab filters and back again (this is a tip not a question)
# How to control string translation through camel to kebab filters and back again (this is a tip not a question)

(Asked by: username_0 on 2023-03-02)

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'
#}

**Tags:** filter, string

---

## 1 answers

### Answer by username_0 on 2023-03-02. Score: 1 | Accepted answer

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'
#}

> **Comments:**
> **username_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 :)  

---

