How do I rewrite these ERB statements for HAML in Rails?

365 views Asked by At

In my layout I want:

<body class="<%= yield (:body_class) %>">

And I also want to call it from another template:

<% content_for :body_class, "my_class" %>
3

There are 3 answers

0
valk On

Voted too quickly. I'm not sure why, but these answers didn't work for me. A friend gave me this answer, which works:

%body{ class: "#{yield(:body_class)}"}

but for the template, is what Marek suggested,

- content_for :body_class, 'my_class'
0
Marek Lipka On

In layout:

%body(:class => yield(:body_class))

and in template:

- content_for :body_class, 'my_class'
0
Inaccessible On

You can use online converter for future reference

Follow this link

http://html2haml.heroku.com/