Question

I add to grunt project https://npmjs.org/package/grunt-contrib-haml

Gruntfile.coffee http://pastebin.com/JzDrVhrA

I run grunt command in the terminal

And when I try to change haml file I get this

➜  caslty  grunt
Running "watch" task
Waiting...OK
> File "index.haml" changed.

Running "haml:compile" (haml) task
Haml error on line 58: Invalid US-ASCII character "\xD0"
    Use --trace for backtrace.
Warning: Haml error on line 58: Invalid US-ASCII character "\xD0"
    Use --trace for backtrace. Use --force to continue.

Aborted due to warnings.
Completed in 1.160s at Tue Jul 30 2013 12:48:17 GMT+0300 (EEST) - Waiting...
OK

My haml file http://pastebin.com/BitjWkjq containe russian characters. But why haml can't handle UTF8?!

How may I fix this?

Était-ce utile?

La solution

When Haml receives the contents of your file from Haml, it is treating it as being in the US-ASCII encoding, and so produces the error with non-ascii characters.

You can specify the encoding of the Haml in a similar way to how you specify the source encoding of a Ruby file with an encoding comment. Add this as the very first thing in your Haml:

- # encoding: UTF-8
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top