I'm trying to nest this
%h1 Admin Menu
%small logged in as: #{session[:username]}
To get something like this
<h1>Admin Menu <small>logged in as: something</small></h1>
But the only way I can get it to display without firing an error is putting them at the same level, say
%h1 Admin Menu
%small logged in as: #{session[:username]}
Which outputs:
<h1>Admin Menu</h1>
<small>logged in as: something</small>
It's probaby something silly but I have no idea this why this wouldn't work?
Haml only allows inline nesting if everything that will be nested is inline. So you can do this:
%h1 Admin Menu
or this:
%h1
Admin Menu
%small logged in as: #{session[:username]}
but not this:
%h1 Admin Menu
%small logged in as: #{session[:username]}
The first form should really be thought of as a convenient abbreviation. It exists so you can take something like this:
%li
One
%li
Two
%li
Three
and just say:
%li One
%li Two
%li Three
I haven't tried, but won't the following work for you?
%h1
Admin Menu
%small logged in as: #{session[:username]}
The other trick is this.
%h1
Admin Menu
%small
logged in as:
=session[:username]
because last 2 lines will be rendered inside "small"-tag
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With