Search code examples
twig

Twig equivalent of lcfirst


I'm not able to find a equivalent of lcfirst php function in Twig, my need is to lower only the first letter of a word ? If such function doesn't exist, what is the best way to do it ?


Solution

  • As discussed in this issue on Github, you could use:

    {{ foo[:1]|lower ~ foo[1:] }}
    

    See this working example.