croxton / Stash

Stash allows you to stash text and snippets of code for reuse throughout your templates.
GNU General Public License v3.0
197 stars 20 forks source link

Clarify stash:extend params #84

Closed timkelty closed 10 years ago

timkelty commented 10 years ago

I wanted to set replace="no" on stash:extend, just as I would on a set or stash:embed.

It appears to work, but the wiki doesn't say it accepts params from set or embed, so I just wanted to make sure that made sense to do.

How about process="start" parse="no", should those work the same too?

timkelty commented 10 years ago

Basically, I'm trying to replace this code with a stash:extend:

{exp:stash:set
  name="content"
  replace="no"
}
  {stash:embed:views:page
    process="start"
    parse="no"
  }
{/exp:stash:set}
croxton commented 10 years ago

{exp:stash:extend} supports all the SET parameters, since you are effectively setting a variable with the embed as the value. You can't pass parameters to the embed beyond embed variables in the form stash:my_var="value".

Extend is really just a convenience tag to make the block/extension template inheritance pattern explicit. Likewise a Stash embed is really just a wrapper for stash:get. It's all about the semantics.

If you need more control over the embed being passed then you can do that explicitly with a {exp:stash:set} wrapped around an embed, as you have above.

croxton commented 10 years ago

Well I'm wrong (forgot!), you can pass parameters to the embed. I'm not sure it's as legible though?

   {exp:stash:extend:block name="content" with="views:page process='start' parse='no'"}
        {stash:my_var}value{/stash:my_var}
   {/exp:stash:extend:block}

Or as a single tag

   {exp:stash:extend name="content" with="views:page process='start' parse='no'"}
timkelty commented 10 years ago

Yep, makes sense to me.

Thanks!

timkelty commented 10 years ago

Is it possible to do this with a list item as well? Or would you have to just do:

{stash:foo}{stash:embed:my_view process="start" parse="no"}{/stash:foo}
croxton commented 10 years ago

Yes, if that is in the host EE template it should work. If not, you may need to prefix the embed with exp: - {exp:stash:embed:my_view ...}

timkelty commented 10 years ago

Thanks!