如何关闭<a> tag right after <img/>?

时间:2017-09-14 10:53:02

标签: ruby sinatra haml

This is what I'm doing:

%p
  %a{href:'/a'}
    %img{src:'/img'}

This is what it looks like in the HTML:

<p>
<a href="/a">
<img src="/img">
</a>
</p>

I need this instead:

<p>
<a href="/a"><img src="/img"></a>
</p>

What should I do to my HAML config or the .haml code? I'm with Sinatra.

2 个答案:

答案 0 :(得分:2)

这看起来像whitespace removal feature

的情况
%p
  %a{href:'/a'}<
    %img{src:'/img'}

或:

%p
  %a{href:'/a'}
    %img{src:'/img'}>

都产生相同的输出:

<p>
<a href='/a'><img src='/img'></a>
</p>

答案 1 :(得分:0)

最干净的选择可能包括css之类的内容:

a > img { display: inline-block }
相关问题