This is a fairly straight forward question... Does preload_replace not work in stash:embed templates? In my embed templates, I tend to set a bunch of preload replace variables for things like channel name and custom field prefix so that if i ever have to change something, one change in the first couple of lines runs through the template and replaces al such instances. But when i try that in a stash:embed template, the preload replace items just render as plain text in the template. Is there a way to get them to work, or is this simply an unavoidable parse order issue?

  • 2
    I have had the same issue. I found a suitable workaround to be using Stash settings/getters in place of preload_replace, but this is not the answer to your question. Commented Dec 2, 2012 at 19:43
  • So far, I've resorted to doing effectively the same thing by passing those same values within the stash:embed itself as variables. Not perfect, but it works. I'm finding it odd, however, that performance of the page in question is reduced at the moment compared to what it was using a native EE embed. Commented Dec 2, 2012 at 20:17

1 Answer 1


Stash doesn't parse preload_replace. But they will work if you use process="start" with the stash embed, since that effectively includes the sub template code in the host template prior to preload_replace being parsed by EE. However, be aware that if you need to access stash vars captured in the host template then you need to use process="end" (the default) due to parse order; also process="start" templates cannot be pre-rendered (parse_stage="set") since the EE parser is not initialised at the point the template is included.

This is off-topic but addresses your comment about performance above:

By default a Stash embed works in a similar way to an EE template, and you will not see a performance gain if you are just including one or two templates in a host template. If you nest your stash templates or use them multiple times then you will notice a gain. And if you 'tune' your embeds - by which I mean choose to pre-render and cache parts or the whole of your template and experiment with parse_depth, parse_vars etc - then you will see significant gains. You should also disable file sync ('stash_file_sync'=false) on your production environment.

The other significant advantage of a stash embed is that you can have multiple cached instances of the same template. That is possible because you can specify a file name separately from the variable name for the embed. This can be helpful for caching things like submenus which might share the same generation code but have different output for the various sections of your site.

  • Thanks Mark. I thought with stash embeds avoiding the full template parser they would see an uptick in performance, which is why I asked. I like your suggestion of the re-usability and portability aspect of the stashed embed - definitely helpful. Commented Dec 3, 2012 at 0:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.