-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Possible 'ifBlock' helper #16
Comments
As discussed in #17, I've added support for |
Released as 2.0. |
All seems to be working great with this code: ---
layout: layout--a
---
{{#extend "master"}}
{{#content "master__head" mode="append"}}
{{#block "head"}}{{/block}}
{{/content}}
{{#content "master__body"}}
<main role="main" class="layout layout--a">
{{!-- {{#or @content.region--a @content.region--b @content.region--c}} --}}
{{#or @content.region--a @content.region--b}}
<div class="row">
{{#if @content.region--a}}
<div class="region region--a row__col row__col--sm-12 row__col--md-12">
{{#block "region--a"}}{{/block}}
</div>
{{/if}}
{{#if @content.region--b}}
<div class="region region--b row__col row__col--sm-7 row__col--md-8">
{{#block "region--b"}}{{/block}}
</div>
{{/if}}
{{#if @content.region--c}}
<div class="region region--c row__col row__col--sm-5 row__col--md-4">
{{#block "region--c"}}{{/block}}
</div>
{{/if}}
</div>
{{/or}}
</main>
{{/content}}
{{#content "master__foot" mode="append"}}
{{#block "foot"}}{{/block}}
{{/content}}
{{/extend}} I just need to find a helper that allows me to use any suggestions @shannonmoeller ? |
@spacedawwwg The syntax is a little gross, but you can actually nest helpers using subexpressions. {{#or @content.region--a (or @content.region--b @content.region--c) }}
...
{{/or}} |
Oh, right. The {{#ifAny @content.region--a @content.region--b @content.region--c}}
...
{{/ifAny}} https://github.com/assemble/handlebars-helpers/blob/v0.6.0/lib/helpers/comparisons.js#L282 |
Thanks @shannonmoeller , that is exactly what I needed!! ...Though, seems to be broken in Assemble. BUT, this guy sorted it: so for now I'm simply using:
Which will get me by. Thank you again though!! |
Awesome! |
@spacedawwwg An issue was submitted related to the {{#ifAny (content "region--a") (content "region--b") (content "region--c")}}
...
{{/ifAny}} It's a breaking change that I released as 3.0. Since you're one of the two people I know are using this feature, just wanted to give you (and any googler's of this thread) a heads up. |
Basically, I'd like to include extra HTML in my layout conditionally, based on whether a particular
{{#content}}
has been included on a page.I wrote a little helper that extends your helpers:
a use example would be:
layout--a.hbs
page.hbs
...The output of page.hbs would not include the
<div class="region region--b">
markup as I did not use{{#content "region--b"}}
I wondered if this might be worth including as part of your helpers?
The text was updated successfully, but these errors were encountered: