【发布时间】:2012-12-21 17:51:55
【问题描述】:
我正在尝试根据找到此主题的建议使用 IE 条件注释。 "[ !IE]" conditional comments in Haml 但是它不起作用,我不知道为什么。
我正在尝试编辑 Ruby on Rails 应用程序,而且我是 HAML 和 Rails 的新手。任何帮助,将不胜感激。
这是我尝试使用的 HAML 代码。
%section#audio-controls
=surround '<!--[if !IE]> -->'.html_safe, '<!-- <![endif]-->'.html_safe do
= audio_tag( '/audios/elder.wav', :controls => 'controls', :id => 'elder_audio' )
=surround '<!--[if IE]> -->'.html_safe, '<!-- <![endif]-->'.html_safe do
= audio_tag( '/audios/elder.mp3', :controls => 'controls', :id => 'elder_audio' )
我也试过这段代码,认为可能是 audio_tag 的问题
%section#audio-controls
=surround '<!--[if !IE]> -->'.html_safe, '<!-- <![endif]-->'.html_safe do
%p
This is not IE
=surround '<!--[if IE]> -->'.html_safe, '<!-- <![endif]-->'.html_safe do
%p
This is IE
【问题讨论】:
-
@benedikt-deicke 使用您的代码时,所有内容都被注释掉,因此它是有效且无条件的注释。
-
条件 cmets 仅在 IE 中受支持,因此在所有其他浏览器中被视为普通 cmets。你是对的,
if !IE声明在这种情况下并没有真正的意义。
标签: ruby-on-rails internet-explorer comments haml