Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Template parser condition bug or quirk?

Quote Reply
Template parser condition bug or quirk?
Alex,

Looking at the help docs, the following:


<%if Logo_Show eq 'Yes' or Username eq LinkOwner%>


should work. But it doesn't.

<%if Logo_Show eq 'Yes' or $Username eq $LinkOwner%>


That works.

When is the $ needed to flag a variable as being a variable?

(at first I thought it was a problem with eq and ==, but a bit of
playing with the values showed it was due to the $'s)


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Template parser condition bug or quirk? In reply to
Spoke too soon... that still isn't working properly.

When I log out, and log back in as a different user, the $Username eq $LinkOwner test still returns true, even though it shouldn't.

The value of Username is 'admin' and the value of LinkOwner is 'pugdog' according to GT::Template::dump.

Gotta figure this out...


Ok... if the LEFT side has no $, but the right side does, it works:

<%if Logo_Show eq 'Yes' or Username eq $LinkOwner%>

This does what I want it to do, but according to the docs, the '$' shouldn't be needed on the right, or is that a problem with the docs? Or maybe I'm misreading it.

Quote:
If the right hand side of the equation starts with a '$', the string will be interpolated as a variable. You can avoid this by using quotes around the right hand value. The left hand side must always be a variable.


I guess I got confused in that the LEFT side shouldn't start with a $, it's implied, and the RIGHT side _SHOULD_ start with a $, even though without '' it's implied.

Confusing :)


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.

Last edited by:

pugdog: Mar 16, 2002, 5:23 PM
Quote Reply
Re: [pugdog] Template parser condition bug or quirk? In reply to
To clarify, in <%if ...%> statements, the left hand side of any comparison is a variable - no $ needed. The right hand side, without a $, will be parsed as a string. If you mean for it to be a variable, the $ at the beginning is required.

That "You can avoid this by using quotes around the right hand value" part simply means that <%if abc eq '$foo'%> will test to see if abc equals '$foo', instead of the variable foo.

Using AND's and OR's in if statements just breaks them up into several LEFT OP RIGHT sets, then goes through until it finds one true (OR) or one false (AND).

It's this way so that simple tags such as <%if foo%> can be used instead of <%if $foo%>. <%if $foo%> will still work, as will: <%if $var1 eq $var2%>

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Jagerman] Template parser condition bug or quirk? In reply to
Actually I see I wasn't really clear either :)

<%if Logo_Show eq 'Yes' or $Username eq $LinkOwner%>

Didn't work. In the first post, it only "appeared" to work, but I didn't edit that post.

$Username will not give the right result, but Username (without the $) will.

Maybe it's in the compound if clause?


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.