haml/haml — pull request #705 by mattwildig (2013-07-28 17:13:39+00:00)
Title: Enable creating "downlevel-revealed" conditional IE comments

Haml currently allows for the creation of IE conditional comments using syntax like this:

```haml
/ [if some condition]
Comment text that some IE browsers will parse
```

which will generate HTML like this:

```html

```

IE actually allows for two kinds of conditional comment, which MS calls “downlevel-hidden” and “downlevel-revealed”. The type that Haml currently creates are “downlevel-hidden”.

“Downlevel-revealed” conditional comments are strictly speaking not actually HTML comments at all, rather they are two markers that surround a section of HTML which will be treated as a comment by IE browsers (depending on the condition). Other browsers will ignore the condition and parse the contents as normal (hence they are “revealed” to these browsers). See [the Microsoft page on conditional comments](http://msdn.microsoft.com/en-us/library/ms537512.aspx) and/or the [Wikipedia page](http://en.wikipedia.org/wiki/Conditional_comment) for more.

This PR adds support for creating downlevel-revealed conditional comments in addition to the existing support for downlevel-hidden comments. Prefixing the conditional part of the comment (i.e. the `[...]`) with `!` causes the comment to be of the downlevel-revealed type.

Additionally, since the downlevel-revealed syntax suggested by MS results in invalid HTML, this provides an option to create either the MS style, or an alternative that is valid HTML.

For example, this Haml

```haml
/ ![if !IE]
Hello
```

will create either the MS style markup:

```html

Hello

```

or the alternalive, valid HTML:

```html

Hello

```

depending on the value of the option.

If people like this and think it should go into Haml I’ll put some documentation together and merge it. In particular I’d be interested to hear opinions on

1. The syntax. I picked `!` because it seems likely that the most common use of this is for the `[if !IE]` case, but this means there will be a little duplication in the Haml (i.e. two `!` close together).

2. The default syntax to use. MS suggested or valid HTML?

3. The name for the option. Currently it is the rather unwieldy `:conditional_comments_valid_html` and defaults to true. Should the option refer to valid HTML, or to MS style (the answer to this may depend on the answer to 2).