Hi, Trying to make sense of escaping cache in an injected template. My simplified test is:
ee template test/cached:
{exp:stash:cache bundle="store_page" replace="yes" } {stash:embed:layouts:test-layout} {exp:stash:extend name="pg_content" with="partials:test-cached" } {/exp:stash:cache}
stash partial:
{stash:nocache} <h1>TEST CACHED PARTIAL</h1> {!--{if segment_3 == "test"} {exp:channel:entries channel="product"} {title} {/exp:channel:entries} {/if}--} {/stash:nocache}
stash layout:
{exp:stash:block name="pg_content"} {!--NO PAGE CONTENT--} {/exp:stash:block}
The front end displays the expected content (an h1 tag), but the channel entries module runs anyway, even though it’s commented out and within a false conditional. The test/cached page variable looks like this in Mustash:
<h1>TEST CACHED PARTIAL</h1> {!--{if segment_3 == "test"} {exp:channel:entries channel="product"} {title} {/exp:channel:entries} {/if}--}
so I was thinking the content in the comments as well as the conditional (ee 2.8.1) would be parsed first, preventing the entries module from running.
I’ve found if I add exp:stash:parse to the partial the cache escapes as I expect and the commented out channel:entries doesn’t run:
{stash:nocache}{exp:stash:parse} .... {/exp:stash:parse}{/stash:nocache}
or instead wrapping the exp:stash:block in the layout with nocache (which I would prefer not to do as sometimes that page content will be cached).
Does it make sense to have to use stash:parse in the partial or is there a better approach here?
|