stacey icon indicating copy to clipboard operation
stacey copied to clipboard

Incorrect treatment of @variables within asset collection

Open thor opened this issue 13 years ago • 3 comments

Let's say I have...

this:
foreach $images do
    <article title="photo: @title">
        <figure>
            <img src="@small" if @title do alt="@title" endif />
            if @variable do @variable endif
            if @title do @variable endif
            @variable
        </figure>
        if @description do <p>@description</p> endif
    </article>
endforeach

... where @variable is "success!" and @title is "expected success!".

... and then I get this:
foreach $images do
    <article title="photo: @title">
        <figure>
            <img src="@small" if @title do alt="@title" endif />
            <!--- missing @variable here -->
            success!
            success!
        </figure>
        if @description do <p>@description</p> endif
    </article>
endforeach

The expected behavior would in my opinion be that the @variable can be checked and returned to true, not false - even though it does have content.

The snippet above is its own partial, referenced from within a get.

thor avatar Feb 22 '12 19:02 thor

This is due to a bug in the old template parser. The new templating system which runs on Twig should does not have this issues.

Alternatively, you can get around it with some creative partial use, placing the two if statements inside a partial should do the trick.

kolber avatar Feb 22 '12 21:02 kolber

Ah, fair enough - sounds good. I'll give that a try and see how it goes.

May I come with a little off topic question: what's the status on 3.0/trunk - what level of stability/usability is there at the moment?

thor avatar Feb 23 '12 17:02 thor

3.0 is stable, so completely ready to use. The documentation is not yet 100% updated, but it should be fairly easy to understand the differences.

The wiki is your best source of reference until the site is updated.

kolber avatar Feb 24 '12 03:02 kolber