HAML 如何制作这条线?
HAML how to craft this line?
我得到了这个代码
%p.date= "Submitted #{time_ago_in_words(@post.created_at)} ago | " |
= link_to "Edit Post", edit_post_path(@post)
我得到了意想不到的结果:
<p class="date">Submitted 10 minutes ago | </p>
<a href="/posts/9/edit">Edit Post</a>
我想在 p 标签内获取一个标签:
<p class="date">Submitted 10 minutes ago | <a href="/posts/9/edit">Edit Post</a></p>
我也试过这个:
%p.date= "Submitted #{time_ago_in_words(@post.created_at)} ago | "
= link_to "Edit Post", edit_post_path(@post)
还有这个:
%p.date= "Submitted #{time_ago_in_words(@post.created_at)} ago "
= "| #{link_to "Edit Post", edit_post_path(@post)}"
在这两种情况下我都得到相同的错误
Illegal nesting: content can't be both given on the same line as %p and nested within it.
看来haml并不知道结局|是 ruby 字符串吗?
如何解决这个问题?
在下一行用缩进将它们分开以嵌套它们:
%p.date
= "Submitted #{time_ago_in_words(@post.created_at)} ago | "
= link_to "Edit Post", edit_post_path(@post)
我得到了这个代码
%p.date= "Submitted #{time_ago_in_words(@post.created_at)} ago | " |
= link_to "Edit Post", edit_post_path(@post)
我得到了意想不到的结果:
<p class="date">Submitted 10 minutes ago | </p>
<a href="/posts/9/edit">Edit Post</a>
我想在 p 标签内获取一个标签:
<p class="date">Submitted 10 minutes ago | <a href="/posts/9/edit">Edit Post</a></p>
我也试过这个:
%p.date= "Submitted #{time_ago_in_words(@post.created_at)} ago | "
= link_to "Edit Post", edit_post_path(@post)
还有这个:
%p.date= "Submitted #{time_ago_in_words(@post.created_at)} ago "
= "| #{link_to "Edit Post", edit_post_path(@post)}"
在这两种情况下我都得到相同的错误
Illegal nesting: content can't be both given on the same line as %p and nested within it.
看来haml并不知道结局|是 ruby 字符串吗?
如何解决这个问题?
在下一行用缩进将它们分开以嵌套它们:
%p.date
= "Submitted #{time_ago_in_words(@post.created_at)} ago | "
= link_to "Edit Post", edit_post_path(@post)