如何使用HAML将图像添加到内容? [英] How to add an image to the contents using HAML?

查看:106
本文介绍了如何使用HAML将图像添加到内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这种标记语言的新功能,我无法找到提及如何处理图像的文档。一两个例子就太棒了。

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.

推荐答案

在任何类型的框架之外:

Outside any kind of framework:

%img(src="/images/loading.gif")

较旧,更冗长但更灵活的语法:

The older, more verbose but flexible syntax:

%img{:src => "/images/loading.gif"}

如果你正在使用Rails,它会生成标签本身:

If you’re using Rails, it will generate the tag itself:

=image_tag "loading.gif"

这篇关于如何使用HAML将图像添加到内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆