Skip to content

{exp:stash:extend}

Mark Croxton edited this page Jun 8, 2015 · 18 revisions

Inject a Stash embed into a variable or block.

Can be used as a single tag, passing parameters to the embed in the form stash:param="value":

{exp:stash:extend name="content" with="views:my_embed" stash:my_var="value"}

Or alternatively as a tag pair, appending a 4th tagpart to the tag, variables can be passed to the injected embed via {stash:var}...{/stash:var} tag pairs:

{exp:stash:extend:block name="content" with="views:my_embed"}
    {stash:my_var}value{/stash:my_var}
{/exp:stash:extend:block}

Parameters

name = [ string ]

The name of the native Stash variable or block that you want to extend (optional).

context = [ string ]

The context of the Stash variable or block you are extending (optional).

with = [ string ]

The Stash embed you wish to inject into the variable or block (required).

escape = [ yes | no ]

Escape the Stash embed from caching (optional, default is 'no').

stash:my_variable="value"

Pass variables to the injected Stash embed as parameters in the form stash:my_variable="value"

Example

/stash_templates/views/wrapper.html (the wrapper view)

{exp:stash:block:content}
    {!-- default content --}
    <h1 class="entry-title">{stash:title}</h1>
    {stash:body}
{/exp:stash:block:content}

/stash_templates/views/_2col.html (a partial view)

<aside>
    {stash:aside_title}
</aside>

<div class="bodycopy">
    Body copy
</div>

/templates/default_site/site/index.html (the viewModel)

Inject the view:_2_col template into the content block, replacing the default content and setting a value for the aside_title placeholder in the injected template:

{stash:embed:views:wrapper}
{exp:stash:extend name="block:content" with="views:_2col" stash:aside_title="Sidebar"}
Clone this wiki locally