2

In a Haml based Padrino solution I have an application.haml like this:

!!!
%html
  %head
    %title "blah"
%body
  #header
    = yield_content :headcontent
  #container
    ...

For :headcontent, in my page (e.g. index.haml) I have

- content_for :headcontent do
  #headcontent
     %h2= "Index header stuff"
#content
  ...

What I want to do is make it so that content pages like index.haml can optionally specify - content for :headcontent. That is I want application.haml to contain some default :headcontent that only is rendered if a page does not do - content for :headcontent.

How do I do this?

tig
  • 3,424
  • 3
  • 32
  • 65

1 Answers1

4

In your main file, you should be able to use content_for?, like this:

- if content_for?(:headcontent)
    = yield_content :headcontent
- else
    something else
drharris
  • 11,194
  • 5
  • 43
  • 56