Conversation
…d issue with new line on Windows (use \r\n instead of \n when running on Windows). Fixed unit tests. Added posibility to run only some tests from the test kit. Use util module instead of deprecated sys module.
lib/haml.js
Outdated
There was a problem hiding this comment.
I am using haml-sprockets in my ruby app and serve haml.js to render my templates on the client. This line causes the following error: 'process is not defined' Is this a Node specific change?
There was a problem hiding this comment.
Yes, it's Node specific which represents the running process.
http://nodejs.org/docs/v0.6.5/api/process.html
I would change
var NEW_LINE_STR = process.platform.match(/^win/i) ? "\r\n" : "\n";
to
var NEW_LINE_STR = "'n";
to be able to run the script in a web-browser.
There was a problem hiding this comment.
So if this pull request is accepted, users would need to manually edit haml.js to be able to continue to use it on the client side?
There was a problem hiding this comment.
that's the good point. I will try to fix this issue to fix the code for web-browsers as well,
thank you for testing. I've been using the library only from node.js.
There was a problem hiding this comment.
no problem :)
I know this isn't strictly the right place to put this...
But I have found that nesting inline javascript in any control structure doesn't work... I am digging in to this but it's a bit of a headache... Have you noticed this?
E.g
:each number in [1,2,3,4]
- var temp = 1 + number
#{temp}
|
I've created a fix for a web-browser. Please, retest. |
Hi Tim,
Thank you for the great project. It is really useful and saved me a lot of time.
Yesterday I found an issue with Haml.render function. For example, if you have a document:
!!!
%html
%head
$title&= title
Then you tries to call Haml.render(doc, { locals: { title: "The test" } }); The call fails with the error of undefined function.
The issue is &= title converted to undefined(title) call what is wrong. I modified the code to initialize escaper function in the render method as well. It has been initialized only in Haml(haml, config) function before.
The second change was to fix how you process end of line characters on Windows. Unit had tests because they expected to have \r\n in a rendered content but there were just \n or \n\n. I fixed the issue: if the platform is Windows then use \r\n otherwise just \n.
I also added a possibility to run only selected tests. For example, node tests.js comments.haml.
I changed deprecated module 'sys' with 'utils' in the tests.js
Please let me know if you have questions or concerns. Otherwise please merge them to the main branch.
Best regards,
Ilya