【发布时间】:2015-02-15 15:22:03
【问题描述】:
类似于this问题,我想在haml文件中使用if子句,具体只在实际有图片url时才显示图片。代码是
%div{ :class => "attachment {{ attachment_type }}" }
%a{ :href => "{{ attachment_url }}", :target=> "_blank"}
%img.image{ :src => "{{ attachment_pic_url }
我正在尝试类似:
:plain
<%if {{attachment_pic_url}}.present? %>
<% { %>
<img class="image" src="{{ attachment_pic_url}}" %> %>"/>
<% } %>
但它抱怨“未关闭的标签”。对这个问题有任何想法吗?或者有更好的方法吗?
【问题讨论】:
-
src="{{ attachment_pic_url %> %>"⇒src="{{ attachment_pic_url }}"