I currently have some haml code which reads as
%span.flagb.flag-gb
this builds me a nice span which the classes:
flagB
flag-gb
(which puts a nice sprite on the page of the gb (great britian) flag
Now I dont want to hard code the gb I have the iso country code which I can access with a
=code
but I am so new I dont know about the best way of replacing the “gb” with the code value
Full code below as how i have it atm
- TZInfo::Country.all_codes.each do |code|
%li
%a(href='#')
%span.flagb.flag-gb
=code
only way I have managed it so far is using pure html
<span class='flagB flag-#{code'></span>
Thanks
The
.classnamesyntax is just a shorthand, you can do it the long way:See the HAML reference on
classandidattributes for more information.