From 064a0f8a3fe2493f6c71cb1cd7dbb1abad3dfea6 Mon Sep 17 00:00:00 2001 From: Shawn Jansepar Date: Fri, 1 Jun 2012 15:32:48 -0700 Subject: [PATCH] Making the defaults for base_root more sane --- tmpl/base_root.tmpl | 46 ++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/tmpl/base_root.tmpl b/tmpl/base_root.tmpl index 14f51e46..18b44790 100644 --- a/tmpl/base_root.tmpl +++ b/tmpl/base_root.tmpl @@ -4,6 +4,10 @@ {! Comment !} - Template comment. Text surrounded by {! will not be rendered. {foo} - Renders the value of key 'foo'. {foo|bar} - Renders the value of key 'foo' through the filter bar. + Normally, text variables are escaped by dust, so

appears as

on user + screen instead of creating a paragraph. |s filter overrides that. + openTag, closeTag and innerHTML tags allow showing parts of HTML elements. + {#foo}..{/foo} - iterate or descend into the key foo. Example: {#header} {logo} @@ -35,7 +39,7 @@ Below is your base template file, which is extended by home.tmpl: {doctype|s} {$html|openTag|s} {$head|openTag|s} - {+baseScriptsBlock} + {+baseScripts} {#lib_import/} {%script} Mobify.enhance(); @@ -49,26 +53,34 @@ Below is your base template file, which is extended by home.tmpl: {%script} Mobify.$('html, #x-root').last().addClass("{#content.templateName}x-{.}{~s}{/content.templateName}"); {/script} - {/baseScriptsBlock} - {+headBlock} + {/baseScripts} + {+head} {$head|innerHTML|s} - {/headBlock} + {/head} {$body|openTag|s} - {+bodyBlock} - {+headerBlock} - {>_header/} - {/headerBlock} - {+contentBlock} + {! Here, we have set up a few blocks that would help you override content from page-specific + templates. For example, if you would like to create a splash page without headers or footers, + you could write {Splash page content

{/body} in a page template. + + If you override block contents, you can bring back old content with a {_SUPER_} reference. + For instance, if a certain page needs to be wrapped in an extra div, its template could add + {{_SUPER_}{/body}. + + Blocks are independent from names of data objects used within. For example, above in {+head} + you can see how content object is being accessed within head block. Reuse of names is merely + a matter of convention. + !} + {+body} + {>_header/} + {+content} {$body|innerHTML|s} - {/contentBlock} - {+footerBlock} - {>_footer/} - {/footerBlock} - {/bodyBlock} - {+scriptsBlock} - {/scriptsBlock} + {/content} + {>_footer/} + {/body} + {+scripts} + {/scripts} - + \ No newline at end of file