Hay, I'm writing some templates but I want to convert " " into "_" within a string.
I want to convert the output of
{{ user.name }}
from something like "My Name" to "My_Name". How do I do this?
A shorter version of Matthijs' answer:
{{ user.name.split|join:"_" }}
Of course it only works when splitting on whitespace.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With