在我的 Controller 中,我设置了一个等于 HTML 字符串的变量,以考虑基本情况。但是,#
注释掉了该行的其余部分。我怎样才能避免这种情况?
@chart_data = "<p id='chart-notice'>If you <a href="#SOME_ID">login to your social media apps</a>, this section will display social analytics.</p>"
注意:这不是 .html.erb
文件,它是 .rb
最佳答案
@chart_data = <<-HTML.strip!
<p id='chart-notice'>If you <a href="#SOME_ID">login to your social media apps</a>, this section will display social analytics.</p>
HTML
或者
@chart_data = %Q{
<p id='chart-notice'>If you <a href="#SOME_ID">login to your social media apps</a>, this section will display social analytics.</p>
}.strip!
或者
@chart_data = "<p id='chart-notice'>If you <a href=\"#SOME_ID\">login to your social media apps</a>, this section will display social analytics.</p>"
注意\
关于ruby-on-rails - Rails # 在 HTML href 中注释掉该行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42841473/