Ian Steffy
Ian Steffy

Reputation: 1234

Using Conditionals to Render templates pending on which Parent Template we are in

I would like to conditionally display templates inside of a larger template as long as the presence of the larger template is True.

in sidebar.hbs

<div id="sidebar-wrapper" class="super-super-float-right-col">
  <div id="sidebar-wrapper" class="super-float-right-col">
    <div id="sidebar-wrapper" class="float-right-col">
      {{#if permit.id}}
          {{render 'applicant'}}
          {{render 'location'}}
      {{else}}
       <h2>Nope!</h2>  
      {{/if}}
    </div>
  </div>
</div>

In application.hbs I call the sidebar and the outlet

{{render sidebar}} {{outlet}}

So technically the sidebar is currently unrelated to the results of the {{outlet}}.

I want to connect the the results of the {{outlet}} with which templates are rendered in sidebar.hbs.

Right now I'm getting "Nope!"

EDIT: I was able to use {{#if this.id}} to make the conditions on the permit.hbs page true. Now I'm trying to figure out how to apply that same logic for rendering

Much love, Ian

Upvotes: 0

Views: 78

Answers (1)

DelphiLynx
DelphiLynx

Reputation: 921

In the application.hbs you have the properties from your ApplicationController. So in the ApplicationController you should do the logic for wether displaying the sidebar or not.

Upvotes: 1

Related Questions