creationix / haml-js

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

:each blah in collection = fail #52

Open kirkbushell opened 12 years ago

kirkbushell commented 12 years ago

I am currently using haml.js on the client side, as the templating solution for sammy - and a core aspect of it simply isn't working.

When I do :each var in collection, and then try and use var, it always comes up undefined. Always.

ilich commented 12 years ago

I think the issue might be related to a couple of fixes I had done. They are not in the master branch yet.

You can try it - https://github.com/ilich/haml-js

I also did a test. It seems to be OK.

HAML markup:

%html %body :each value in collection %div&= value

JavaScript:

var fs = require("fs"), Haml = require("./haml-js/lib/haml.js"), collection = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

var content = fs.readFileSync("./test.haml", "UTF-8"); var html = Haml.render(content, { locals: { collection: collection }});

console.log(html);

Please, attach you HAML markup in case you still have the issue.

kirkbushell commented 12 years ago

Good to know this has been fixed - unfortunately a tad too late for us to use it in the project (which is a real shame :(). Keep up the good work mate, hopefully we can use it in our next js project :)