This code in helper:
def dgtags
if params[:controller]=='my_controller'
javascript_include_tag('dygraph-combined.js') <<
tag(:meta, :http_equiv => 'X-UA-Compatible', :content => 'IE=EmulateIE7; IE=EmulateIE9') <<
'<!--[if IE]>'.html_safe <<
javascript_include_tag('excanvas.compiled.js') <<
'<![endif]-->'.html_safe
end
end
produces following output:
<script src="/javascripts/dygraph-combined.js?1338036501" type="text/javascript"></script><meta content="IE=EmulateIE7; IE=EmulateIE9" http_equiv="X-UA-Compatible" /><!--[if IE]><script src="/javascripts/excanvas.compiled.js?1237712986" type="text/javascript"></script><![endif]-->
How to insert line breaks between tags? Like this:
<script src="/javascripts/dygraph-combined.js?1338036501" type="text/javascript"></script>
<meta content="IE=EmulateIE7; IE=EmulateIE9" http_equiv="X-UA-Compatible" />
<!--[if IE]><script src="/javascripts/excanvas.compiled.js?1237712986" type="text/javascript"></script><![endif]-->
The ‘\n’ or ‘\n’.html_safe does not help – it produces literally \n.
You have to use double quotes
"Use
"\n"not'\n'You can get more detailed information here: http://en.wikibooks.org/wiki/Ruby_Programming/Strings
I have changed your code a bit. Better approach is to join all elements using
"\n". Also you can usecontroller_nameinstead ofparams[:controller].