Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

str_replace in Twig

I want to do a simple str_replace in my twig template. I'm new to twig and probably I need to add new filter or sth like that or to use existing. How can I do this? Where can I find list of filters available?

like image 783
umpirsky Avatar asked Feb 09 '11 10:02

umpirsky


1 Answers

Use this to replace | with - and replace , width .:

{{age|replace({'|': "-", "," : "."})}} 

Example input 31|60, comes out as 31-60.

like image 179
websky Avatar answered Sep 22 '22 21:09

websky