HAML:语法错误,意外的 tIDENTIFIER,需要 keyword_end
HAML: syntax error, unexpected tIDENTIFIER, expecting keyword_end
如何将此代码转换为 HAML?
<h4 class="media-heading"><%= link_to comment.user.name, comment.user.profile_url, target: '_blank' %> says
<small class="text-muted">[at <%= comment.created_at.strftime('%-d %B %Y, %H:%M:%S') %>]</small></h4>
我试过了,但是显示错误:
%h4.media-heading
= link_to message.user.name, message.user.profile_url, target: '_blank' says
%small.text-muted [at '#{= message.created_at.strftime('%-d %B %Y, %H:%M:%S')}']
如果您将它留在同一行,HAML 应该如何知道悬挂的 "says" 是什么?
HAML中的=
表示一行Ruby。您不能在同一行中随意输入单词并期望 Ruby 理解什么是 Ruby 以及什么是普通的旧字符串。
%h4.media-heading
= link_to message.user.name, message.user.profile_url, target: '_blank'
says
%small.text-muted [at '#{= message.created_at.strftime('%-d %B %Y, %H:%M:%S')}']
如何将此代码转换为 HAML?
<h4 class="media-heading"><%= link_to comment.user.name, comment.user.profile_url, target: '_blank' %> says
<small class="text-muted">[at <%= comment.created_at.strftime('%-d %B %Y, %H:%M:%S') %>]</small></h4>
我试过了,但是显示错误:
%h4.media-heading
= link_to message.user.name, message.user.profile_url, target: '_blank' says
%small.text-muted [at '#{= message.created_at.strftime('%-d %B %Y, %H:%M:%S')}']
如果您将它留在同一行,HAML 应该如何知道悬挂的 "says" 是什么?
HAML中的=
表示一行Ruby。您不能在同一行中随意输入单词并期望 Ruby 理解什么是 Ruby 以及什么是普通的旧字符串。
%h4.media-heading
= link_to message.user.name, message.user.profile_url, target: '_blank'
says
%small.text-muted [at '#{= message.created_at.strftime('%-d %B %Y, %H:%M:%S')}']