Gulp-haml task causing an error on OSX 10.10.4

Alex Pittendreigh

I am using an iMac running OSX 10.10.4 and using the following tools (among others) to create a demonstration website.

haml v4.0.6 , gulp v3.9 , gulp-haml v0.1.5

I have the following snippet in an index.haml file in the haml folder of my development site

/ HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries
/[if lt IE 9]
  %script(src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js")
  %script(src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js")

When I run the haml command direct from the command line it will produce the following html code

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
  <script src='https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js'></script>
  <script src='https://oss.maxcdn.com/respond/1.4.2/respond.min.js'></script>
<![endif]-->

Which is exactly what i was expecting and got. However, I have the following task set up in my gulpfile.js file

gulp.task('haml', function() {
    gulp.src('haml/*.haml')
        .pipe(haml())
        .on('error', errorLog)
        .pipe(gulp.dest('./'));
});

Whenever I run this task with the above haml snippet in it, I get a huge crash basically saying that there is a "SyntaxError: Unexpected identifier" followed by a long stack trace going down into the gulp-haml code.

BTW, the errorLog function near the top of the gulpfile.js file is simply:

function errorLog(error) {
    console.error.bind(error);
    this.emit('end');
}

Taking the above haml code out of the file and running the task will however create the html file without error.

I need some help here. Is there something I'm doing wrong, or is there a bug in the tool setup I'm using.

robertklep

I'm guessing that your haml CLI tool is the Ruby-based version and not the Node-based version (which is called haml-js). The Node version doesn't handle the IE conditional properly, which is a known issue.

This works, though:

/ HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries
<!--[if lt IE 9]>
  %script(src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js")
  %script(src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js")
<![endif]-->

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related