creationix / haml-js

Haml ported to server-side Javascript. This is a traditional server-side templating language. Tested with node-js
MIT License
900 stars 109 forks source link

IE problems #14

Closed jacquescrocker closed 14 years ago

jacquescrocker commented 14 years ago

Seems like haml.js is using some JS methods that dont exist in IE

[].forEach

and matcher.regexp

probably others. I'm working through them 1 by 1. Am i missing a required compatibility library?

creationix commented 14 years ago

no, you're right. I never tested on IE because I don't usually support it. Mozilla has written compat functions you can copy paste into a small compat library. Here is the one for forEach:

https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Objects/Array/ForEach

jacquescrocker commented 14 years ago

Another big problem is you have regex methods that you are executing as a function. For example

reg = /something/i
reg("something")

this works fine in firefox, but explodes in IE. Needs to use .exec

found a few places so far where you're doing this. i'll submit a patch to fix

creationix commented 14 years ago

cool, thanks.

jacquescrocker commented 14 years ago

got it to stop erroring out, however the actual output on IE is a mess. Very often it just spits out the template file

Would you mind if I patched a warning on the README that its not IE compatible? This is going to bite a lot of people in the ass

creationix commented 14 years ago

Is the generated html not correct? If it is, then it's not a problem with haml, but the way you're inserting the html into the dom. Honestly, I never intended this library to be used in the browser at all, but I assume that innerHTML or something should do the right thing.

jacquescrocker commented 14 years ago

Right, the generated HTML is not correct in IE. Works great in Firefox, Chrome, Opera, etc.

Yeah, looks like I probably shouldnt have tried to use this for browser templating. Ah well, live and learn :-)

creationix commented 14 years ago

I'm interested to see why it's wrong in ie6, the code doesn't use dom or anything browser specific. As long as your compat library is right, is should work the same on IE

jacquescrocker commented 14 years ago

BTW... not just IE6. All IE (6, 7, 8). I havent even tried it in IE6 actually, just ie7 and ie8

jacquescrocker commented 14 years ago

BTW... I'd now recommend against including my fork commits

In the end, I just didnt really quite understand what "server side javascript" meant :-)

jacquescrocker commented 14 years ago

closing issue

rajatvig commented 14 years ago

I've made some changes and added on a bunch of ie compatibility functions to make it work on a client side as well. The changes require jQuery.