From 7f43d7fed098f619f72342f66bd2ed4f4e96368b Mon Sep 17 00:00:00 2001 From: kpdecker Date: Fri, 14 Aug 2015 15:26:48 -0500 Subject: [PATCH] Documentation for block partials This is the documentation for https://github.com/wycats/handlebars.js/pull/1076 --- src/pages/partials.haml | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/pages/partials.haml b/src/pages/partials.haml index 6849db6..338287c 100644 --- a/src/pages/partials.haml +++ b/src/pages/partials.haml @@ -62,3 +62,52 @@ This is particularly useful for exposing data from parent contexts to the partial: :html {{> myPartial name=../name }} + +%h2#partial-block + Partial Blocks + +.contents + .bullet + .description + The normal behavior when attempting to render a partial that is not found is for the implementation to throw an error. If failover is desired instead, partials may be called using the block syntax. + + :html + {{#> myPartial }} + Failover content + {{/myPartial}} + + .notes + Which will render Failover content if the myPartial partial is not registered. + + .bullet + .description + This block syntax may alow be used to pass templates to the partial, which can be executed by the specially named partial, @partial-block. A template of + :html + {{#> layout }} + My Content + {{/layout}} + + .descrption + with the layout partial containing + :html + Site Content + {{> @partial-block }} + + .description + Would render + :html + Site Content + My Content + + .notes + When called in this manner, the block will execute under the context of the partial at the time of the call. Depthed paths and block parameters operate relative to the partial block rather than the partial template. + + :html + {{#each children as |child|}} + {{#> childEntry}} + {{child.value}} + {{/childEntry}} + {{/each}} + + .notes + Will render child.value from this template, not the partial.