Replacing content returned by xen:raw

Myke623

Well-known member
I have some template code as follows:
Code:
{xen:raw $myContent}

which mainly contains text and some smiley code, hence the need for the xen:raw tag.

However, within this content I'd like to replace all occurrences of the greater-than symbol (>) with the unicode geometric shape ► (►).

I've tried to nest my own helper in there:
Code:
{xen:raw {xen:helper myhelper, $myContent} }

but that produces a template error on save (Invalid variable reference).

One work-around would be to create a new smiley image to replicate the right-pointing pointer shape, but I feel there's a much simpler solution.

Anyone know of a way to achieve this?
 
Your content in the raw block basically contains HTML so replacing > is going to cause you problems.

Unless the characters you are replacing are encoded in which case you could do a replacement on >

Anyway, you can do what you tried already with the helper but it would have to be the other way around.

{xen:helper yourhelper, {xen:raw $var}}
 
Is there a way I can encode the > prior to it saving (e.g. via a form)?

If not, then I guess I'll have to use a different character other than > to replace.
 
Is there a way I can encode the > prior to it saving (e.g. via a form)?
Actually, never mind that.

Since the helper is running first (i.e., before the xen:raw outputs html), there's no harm in replacing the >'s since they're already encoded.

My helper code is simply thus:
Code:
return preg_replace('/>/', '►', $content);
 
Top Bottom