Hi; I’ve got a bunch of templates that all use the same snippet, combined with a preload_replace variable, to provide a lighter-weight alternative to embedded templates (as described here). Prior to EE 2.9.0 it was working perfectly, but now the template throws an error, because the snippet contains nested Conditionals which are are evaluating before the preload_replacement has been carried out (previously the conditionals—or least some of them—were evaluating after the preload_replacement, because they are what used to be considered Advanced Conditionals).
My question is this: is this expected behaviour brought about by the change in conditional parsing in 2.9.0, or is it a bug? And if it’s expected behaviour then is there any way around it (other than using an embed)?
Here is the relevant portion of the code (the rest of the template is pretty mundane)—both the channel:entries loop that references the snippet, and the snippet itself.
Channel:entries loop:
{exp:channel:entries channel="news"}
{!-- ...some other fields… --}
{preload_replace:pre_gridfield="name_of_grid_field"}
{snp_gridfield_output}
{!-- ...some more fields… --}
{/exp:channel:entries}Snippet (named snp_gridfield_output):
{{pre_gridfield}}
{exp:typogrify:widont}{{pre_gridfield}:text}{/exp:typogrify:widont}
{if {pre_gridfield}:image}
{if {pre_gridfield}:caption != "" || {pre_gridfield}:credit != ""}
<figure>
{if {ress} 480}{{pre_gridfield}:image:mobilesize}{if:else}{{pre_gridfield}:image}{/if}
<figcaption>{{pre_gridfield}:caption}<span>{if {pre_gridfield}:credit != "" && {pre_gridfield}:caption != ""} / {/if}{if {pre_gridfield}:credit}© {{pre_gridfield}:credit}{/if}</span></figcaption>
</figure>
{if:else}
{if {ress} 480}{{pre_gridfield}:image:mobilesize}{if:else}{{pre_gridfield}:image}{/if}
{/if}
{/if}
{/{pre_gridfield}}There are lots of nested conditionals in that snippet, but the one that seems to be throwing the template error is the outermost one. The error page displayed reads:
Error
You have an invalid conditional in your template. Please review your conditionals for an unclosed string, invalid operators, a missing }, or a missing {/if}.
Parser State: Unexpected ‘image’ (VARIABLE); expected RD in Snippet “snp_gridfield_output” on line 3.Thanks in advance for any insight into whether this is a bug or simply an expected consequence of the new conditionals. (NB. I’ve also posted this problem over at Stackexchange).