Skip to content

Commit

Permalink
Documentation for block partials
Browse files Browse the repository at this point in the history
This is the documentation for handlebars-lang/handlebars.js#1076
  • Loading branch information
kpdecker committed Aug 14, 2015
1 parent 7754b75 commit 7f43d7f
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/pages/partials.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>Failover content</code> if the <code>myPartial</code> 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, <code>@partial-block</code>. A template of

This comment has been minimized.

Copy link
@mmun

mmun Aug 14, 2015

Typo: alow -> also

:html
{{#> layout }}
My Content
{{/layout}}

.descrption
with the <code>layout</code> 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 <code>child.value</code> from this template, not the partial.

0 comments on commit 7f43d7f

Please sign in to comment.