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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 292k
  • Answers 292k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You do this if you wish to connect as a… May 13, 2026 at 6:15 pm
  • Editorial Team
    Editorial Team added an answer I've had problems like this in IE before. You should… May 13, 2026 at 6:15 pm
  • Editorial Team
    Editorial Team added an answer You can try setting your own error documents in .htaccess… May 13, 2026 at 6:15 pm

Related Questions

My 7 year old would like to learn, how to program? (his idea not
I have an interesting problem. The basis of the problem is that my last
This question is a spin-off/evolution of this question . (That question got marked as
I'm interested in putting together my first online game using Flash as the client
I am new to threads and in need of help. I have a data

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.