我爱haml,但是有一个问题一直困扰着我,父节点的问题可能存在也可能不存在。
在下面的代码中,我想要超链接一些文本,但前提是我还没有查看回复(由部分中存在的线程变量表示)。在这种情况下,我必须重复表达链接文本的代码。
链接文本代码似乎没有资格获得帮助程序,而且它非常小,我觉得不值得帮助。在这种情况下,是否有一种简单的方法可选择包含父节点?
.text
%h2
-if defined?(threaded)
="#{request.post_type.humanize}: #{request.title}"
-else
%a{ :href => request_path(request) }
="#{request.post_type.humanize}: #{request.title}"
提前致谢。
注意:的
此问题已在此处得到解答:How can I do to write "Text" just once and in the same time check if the path_info includes 'A'?
正确答案IMO在这种情况下是使用content_for块。
答案 0 :(得分:0)
此问题已在此处得到解答:How can I do to write "Text" just once and in the same time check if the path_info includes 'A'?
正确答案IMO在这种情况下是使用content_for块。