Created
August 10, 2012 16:36
-
-
Save croxton/3315420 to your computer and use it in GitHub Desktop.
Dynamic Stash embeds using context
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {!-- file at stash_templates/my_context/my_template.html --} | |
| {!-- standard embed syntax --} | |
| {stash:embed name="my_context:my_template"} | |
| {!-- shortcut embed syntax --} | |
| {stash:embed:my_context:my_template} | |
| {!-- set embed name dynamically from a Stash variable --} | |
| {stash:embed name="{stash:layout}"} | |
| {exp:stash:set_value name="layout" value="my_context:my_template"} | |
| {!-- using the static context pointer '@' --} | |
| {exp:stash:context name="my_context"} | |
| {stash:embed name="my_template" context="@"} | |
| {!-- or use the pointer in the name parameter --} | |
| {stash:embed name="@:my_template"} | |
| {!-- for multiple cached instances of same base template, use the file_name parameter --} | |
| {stash:embed name="another_instance_of_my_template" file_name="@:my_template"} | |
| {!-- 'template partials' example using dynamic context --} | |
| {stash:embed name="my_layout" context="@"} | |
| {exp:switchee variable="{segment_1}" parse="inward"} | |
| {!-- left to right layout for latin languages --} | |
| {case value="en|fr|it"} | |
| {!-- template at stash_templates/ltr/my_layout.html --} | |
| {exp:stash:context name="ltr"} | |
| {exp:stash:set name="content"}My language specific content{/exp:stash:set} | |
| {/case} | |
| {!-- right to left layout for arabic --} | |
| {case value="ar"} | |
| {!-- template at stash_templates/rtl/my_layout.html --} | |
| {exp:stash:context name="rtl"} | |
| {exp:stash:set name="content"}بلدي محتوى لغة معينة{/exp:stash:set} | |
| {/case} | |
| {/exp:switchee} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment