Closed harmdewit closed 8 years ago
Thank you for using Hamlit and reporting this.
Maybe this is caused by the 'ugly-only' support, which i'm ok with. But having different results caused by using a block or not seems confusing.
Actually this happens on both pretty mode and ugly mode of original Haml.
%div
%a{ href: '#' }
a
= link_to '#' do
b
<div>
<a href='#'>
a
</a>
<a href="#">b
</a>
</div>
<div>
<a href='#'>
a
</a>
<a href="#">b
</a></div>
<div>
<a href='#'>
a
</a>
<a href="#">b
</a></div>
Since Hamlit is aimed to be similar to Haml's ugly mode as much as possible, at least this is not a bug in Hamlit.
In both %a
and link_to
, "This is a link\n"
is the block's content and they're not different. The different things are the fact that nested %a
prepends "\n"
to the nested content and the one that link_to
with block does not. It's the issue of link_to
helper with block and out-of-scope for Hamlit.
In addition, if you want to trim newline inside link_to
's block, you can use <
operator.
%div<
= link_to '#' do
This is a link
%div<
%a{ href: '#' }<
This is a link
is rendered to:
<div><a href="#">This is a link</a></div>
<div><a href='#'>This is a link</a></div>
Thanks for the explanation. Just seems strange that a normal content_tag
without block has a preceding \n
and a content_tag
without block doesn't. But if it's internal to rails and standard haml works the same way, then i agree it should be kept as it is.
When using a rails helper like
link_to
, there is a difference in output when using a block or not. For example:Result:
All variations produce newlines between the
<a>
's, except for the lastlink_to
with block. This results in the same missing margins as seen in this issue.Maybe this is caused by the 'ugly-only' support, which i'm ok with. But having different results caused by using a block or not seems confusing.