Forum
Replace Tag
I am trying to replace spaces with hyphens using the replace tag. For example. the content might be "Joe Smith" and I want to output "Joe-Smith". Here's my code
<perch:content id="staff_last_name" type="text" label="Staff Last Name" replace=" |-">
but the tag as constructed here is ignored. I've verified that Replace is otherwise working by replacing other alpha characters in the string.
Any thoughts on how to coax Replace into working with a space between characters?
Hello JP,
I think you need to use a Template Filter: https://docs.grabaperch.com/api/template-filters/
Here's a post discussing something very similar (solution included): https://forum.grabaperch.com/forum/01-20-2018-remove-spaces-from-field
Otherwise the next closest thing would be the
urlify
attribute, but that will also convert to lowercase.Thank you Hussein! That was the ticket.