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

Unexpected token > #51

Closed andrewtheone closed 11 years ago

andrewtheone commented 12 years ago
%div{:style => "position: relative; margin: 0 auto; width: 500px; height: 300px"}
  .wrapper
    .navigation
      %ul.navigationList
        %li.navigationItem
          %a{:href => "a"} aha
        %li.navigationItem.itemActive
          %a{:href => "b"} b
        %li.navigationItem
          %a{:href => "b"} c
    #content.content

I'm trying to parse this haml, and it throws the error: Syntax error: Unexpected token > Additional: haml.js:637

andrewtheone commented 12 years ago
with(locals || {}) {
  try {
   var _$output="<div =\"" + html_escape(style => "position: relative; margin: 0
 auto; width: 500px; height: 300px") + "\">" +
"<div class=\"wrapper\"><div class=\"navigation\"><ul class=\"navigationList\"><
li class=\"navigationItem\">" +
"<a =\"" + html_escape(href => "a") + "\">" +
"aha</a></li><li class=\"navigationItem itemActive\">" +
"<a =\"" + html_escape(href => "b") + "\">" +
"b</a></li><li class=\"navigationItem\">" +
"<a =\"" + html_escape(href => "b") + "\">" +
"c</a></li></ul></div></div><div class=\"content\" id=\"content\"></div></div>";

 return _$output;  } catch (e) {
    return "\n<pre class='error'>" + html_escape(e.stack) + "</pre>\n";
  }
}

This is the full error message

andrewtheone commented 12 years ago

Problem solved, only thing i had to do is use "key:'value'" syntax... i thought this package smart enough to know the haml syntax, but i was wrong

gotoAndBliss commented 11 years ago

@andrewtheone Could you explain more what you did here? I'm not sure I understand and have been plagued by this bug for months.

aaronblohowiak commented 11 years ago

The package supports key:value or key=value, not key=>value. Please check the tests.

mrpollo commented 9 years ago

:+1: thanks for solution, saved my ass :)