Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for block partials #120

Merged
merged 2 commits into from
Aug 24, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 allow be used to pass templates to the partial, which can be executed by the specially named partial, <code>@partial-block</code>. A template of
: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.