Rails标记帮助程序未按预期显示

def amount_html
  h.tag.span do
    h.tag.del do
      'value1'
    end
    'value2'
  end
end

我得到:

<span> value2 </span>

代替:

<span><del>value1</dev> value2 </span>

我需要加入联接吗?如果可以,怎么办?

nanyun1 回答:Rails标记帮助程序未按预期显示

标签只是字符串,您需要将它们连接起来。另外请注意,标签默认情况下是转义的,因此您无需在标签上调用class CustomPasswordChangeView(LoginRequiredMixin,PasswordChangeView): """ Overriding Allauth view so we can redirect to profile home. """ def get_success_url(self): """ Return the URL to redirect to after processing a valid form. Using this instead of just defining the success_url attribute because our url has a dynamic element. """ success_url = reverse('users:user-detail',kwargs={'username': self.request.user.username}) return success_url

h

或者如@mu所指出的,您也可以使用concat,它将每个字符串添加到输出缓冲区中,而无需手动def amount_html tag.span do tag.del do 'value1' end + 'value2' end end 将它们在一起:

+
本文链接:https://www.f2er.com/3169339.html

大家都在问