If statements don't seem to work properly inside DIV tags (solution provided)

thetruespin
06 Sept 2016, 08:03
@title test
@set love = 9

{if love<10:show me}

The above code works as expected. The line "show me" will be displayed if the attribute love is less than 10.

However, if the above code is wrapped in a div in order to style via CSS, like this:

@title test
@set love = 9

<div>
{if love<10:show me}
</div>

You will receive no output.

Strangely, the following code does work, even when wrapped in a DIV:

@title test
@set love = 9

<div>
{if love=9:show me}
</div>

As does:

@title test
@set love = 9

<div>
{if love>8:show me}
</div>

I suspect what is happening is that the < character is being interpreted as HTML in the less than statement, and breaking the attribute call. Sadly the scripting used by Squiffy doesn't appear to have an easy escape function to prevent this?

Can anyone help?


thetruespin
06 Sept 2016, 08:10

I think I found a solution, albeit a dirty one. Squiffy doesn't seem to support an escape function for < tags, but you can use the Ascii code:

&lt;

As a substitute. So, using the above example, the code would become:

@title test
@set love = 9

<div>
{if love&lt;10:show me}
</div>

This seems to render correctly.

I'm not completely happy with the solution a it's a bit messy, but unless an escape function exists it's probably the easiest solution.