New to this tagging language, and I'm having trouble finding documentation mentioning how to work with images. An example or two would be fantastic.
Btw, I did refer to this discussion, but not sure if that's what I need.
In Haml, we write a tag by using the percent sign and then the name of the tag. This works for %strong , %div , %body , %html ; any tag you want. Then, after the name of the tag is = , which tells Haml to evaluate Ruby code to the right and then print out the return value as the contents of the tag.
To use Haml with Rails, simply add Haml to your Gemfile and run bundle . If you'd like to replace Rails's Erb-based generators with Haml, add haml-rails to your Gemfile as well.
Outside any kind of framework:
%img(src="/images/loading.gif")
The older, more verbose but flexible syntax:
%img{:src => "/images/loading.gif"}
If you’re using Rails, it will generate the tag itself:
=image_tag "loading.gif"
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