Question

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?

Était-ce utile?

La solution

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

- if content_for?(:headcontent)
    = yield_content :headcontent
- else
    something else
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top