Rails # 在 HTML href 内注释掉该行
Rails # within HTML href comments out the line
在我的控制器中,我设置了一个等于 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>"
关注\
试试下面的代码:
@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 字符串的变量,以考虑基本情况。但是,#
注释掉了该行的其余部分。我该如何逃脱?
@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>"
关注\
试试下面的代码:
@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>"