Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Template Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Whitespace in string comparison

Go to End

3 Posts   2947 Views


Community Member, 1 Post

21 January 2009 at 9:20am

Edited: 21/01/2009 9:28am

I'm a new user and I've been extending my SS install over the past few days. Everything has been smooth sailing until today when I tried evaluating a string in the template that contained whitespace. If I try..

<% if MenuTitle != "Contact Us" %>


<% if MenuTitle != 'Contact Us' %>


<% if MenuTitle != {Contact Us} %>


(anything, really)

I receive the same error about an unexpected } in

I checked the SSViewer.php file and found the regexs that replace the template code and couldn't find any allowance of whitespace in them.

Is there something I'm missing? A special way to escape?

Any help is greatly appreciated, thanks.



Forum Moderator, 4102 Posts

21 January 2009 at 9:56am

Not too sure that will work. I always compare URLSegments since they're whitespace free.


Community Member, 501 Posts

21 January 2009 at 9:58am

No you're not missing anything.

The template parser is kept very simple.

In your case you could use

<% if InSection(contact-us) %>


<% if URLSegment = contact-us %>

to overcome this issue.