Reputation: 4940
Just adopted an application using HAML and trying to write on top of it (never used HAML before). Been looking at different resources like haml.info and this S.O post. However, the S.O. post is actually incorrect in a couple ways. I'm trying to render your basic bootstrap flash messages.
So far I have this structure:
- flash.each do |key, value|
.alert.alert-dismissable{ :class => 'alert-#{key}' }
%button.close{ :type => 'button', :data => { :dismiss => 'alert' }, :aria => { :hidden => 'true' } }
%i.icon-remove-sign
= value
Yea that's right, I have to go back to Bootstrap 2 on this one. Seems like everything works, except this line here:
.alert.alert-dismissable{ :class => 'alert-#{key}' }
This gets rendered to HTML as
<div class="alert alert-#{key} alert-dismissable">
Obviously, I want #{key}
to be replaced with the key coming from the controller (success
, danger
, notice
, etc) Would love to know what is wrong here. Thanks for taking a look at it.
Upvotes: 3
Views: 471
Reputation: 10406
"alert-#{key}"
In ruby you can't use #{}
to escape single quoted strings.
Upvotes: 3