concordusapps / grunt-haml

Process HAML templates to precompiled JavaScript or rendered HTML.
https://npmjs.org/package/grunt-haml
MIT License
41 stars 28 forks source link

Conditional comments support #30

Open xsuii opened 10 years ago

xsuii commented 10 years ago

I would like to use the conditional comments feature by using grunt-haml. But got some error. This is my grunt task configuration:

{
    haml: {
        files: {
            expand: true,
            cwd: 'app',
            dest: '.tmp',
            src: '{,*/}*.haml',
            ext: '.html'
        }
    }
}

and this is my .haml code:

!!! 5
/[if IE]
  %html(class="no-js lt-ie9 lt-ie8 lt-ie7")

The error:

Running "haml:files" (haml) task
with(locals || {}) {
  try {
   var _$output="<!DOCTYPE html>\n"
"<!--adfdf\n\n%html(class="no-js lt-ie9 lt-ie8 lt-ie7")-->";
 return _$output;  } catch (e) {
    return "\n<pre class='error'>" + html_escape(e.stack) + "</pre>\n";
  }
}
>> SyntaxError: Unexpected identifier
Warning: Haml failed to compile. Use --force to continue.

Aborted due to warnings.
taystack commented 10 years ago

What you are looking for is:

%haml.no-js.lt-ie9.lt-ie8.lt-ie7

Your notation is almost there, but why waste the time with all the characters when haml is meant to make your life easier.

%haml(class: 'class1 class2')

Both will work, but which one looks better? Don't forget the colon for assignment!

xsuii commented 10 years ago

@taystack Ok, it is a little mistake here, thanks for your reminding. But my point is the support of conditional comments feature which means the compiling of

/[if IE]
    %html

doesn't work well.

taystack commented 10 years ago

@xsuii Understood. I figured we could address the error message and take it from there. Happy coding!

xsuii commented 10 years ago

@taystack Appreciate it.