Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 501011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:08:45+00:00 2026-05-13T06:08:45+00:00

My question is very simple. I will ask it first in case the answer

  • 0

My question is very simple. I will ask it first in case the answer is obvious, and then I will explain what I mean, in case it’s not obvious.

Is it considered ok to make your main ‘yield’ call from a partial instead of doing it directly from your layout.html.haml file? Does doing so result in any kind of performance loss.


Explanation…

I have one layout file called application.html.haml.

I want my main content to take up the full page width unless there is a sidebar present for that page.

If there is a sidebar then I want the main content to take up 66% page width and the sidebar to use up the remaining space.

I have the following in my layout:

#content
  - if show_sidebar?    
    #main
      = yield
    #sidebar
      = yield(:sidebar)
  -else
    = yield

The content div is 100% page width. If no sidebar is present then the ‘yield’ results go into this div. If there is a sidebar then the main yield goes into a div called #main which is 66% page width.

Great, this works fine.

Now, in order to keep my main view tidy, I have refactored my code a little so that it now looks like this:

#content
  - if show_sidebar?
    - render :partial => 'main_with_sidebar'
  -else
    = yield

And then in the partial _main_with_sidebar.html.haml I have this:

    #main
      = yield
    #sidebar
      = yield(:sidebar)

So everything is the same, except for the fact that whenever there is a sidebar present, the main yield is called from a partial.

And so my question regards whether or not this is considered best practice. Or should I just stick to having a slightly messier application.html.haml file and get rid of the partial? It doesn’t seem to cause any problems but I’d like to know if I’m doing something wrong before I go too far with it.

Yes it might seem dumb to some of you guys, but I’m a designer rather than a dev and this sort of thing is new to me….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:08:46+00:00Added an answer on May 13, 2026 at 6:08 am

    I would simply create a new layout for the “layout with sidebar”

    views/layouts/application.html.haml
    views/layouts/sidebar.html.haml
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a very simple question with a simple answer, but it is not
I am learning LINQ and have a very simple question that I think will
very simple question. Lol i am embarassed to ask this cause i am usually
Very simple question, is there any cloud server enviroments avaliable these days for us
Here's a very simple question. I have an SP that inserts a row into
I have a very simple question. I want to test whether a particular port
This must be a very simple question, but I don't seem to be able
I know this is a darn simple question, but I'm very used to using
Warning - I am very new to NHibernate. I know this question seems simple
Firs off all, I'm not sure if there will be any simple and straight

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.