nbsp instead of whitespace

I’m trying to figure out some way of getting rx:displaytitle to have nbsp instead of whitespace (so that some menus render properly)

i.e.
#set($label = $subNode.getProperty(“rx:displaytitle”).String)

label currently renders:
“Vision and Mission”

And it needs to be: (I’m using commas instead of &)
“Vision,nbsp;and,nbsp;Mission”

Any ideas?

You could try the .replaceAll function of java strings. Something like this may do the trick (%=& in replace string):

#set($label = $subNode.getProperty("rx:displaytitle").String.replaceAll(" ","%nbsp;"))

I would actually use trim first (get rid of leading and trailing spaces), then the replaceAll:

#set($label = $subNode.getProperty("rx:displaytitle").String.trim().replaceAll(" ","%nbsp;"))

Thanks!!! That worked perfectly :slight_smile: