Javascript 中间人应用程序Haml语法错误,带有把手

Javascript 中间人应用程序Haml语法错误,带有把手,javascript,ruby,haml,handlebars.js,middleman,Javascript,Ruby,Haml,Handlebars.js,Middleman,我正试图这样做,并建立使用中间人应用程序 %script{:type => "text/html", :id => "showItem"} {{#items}} %li %a{href: "#{{id}}"} {{showName}} {{/items}} 问题是当{{id}}在另一个{}中时,这一行%a{href:“{{id}}} 这里是错误 SyntaxError at /show.html /show.haml:110: syntax error, une

我正试图这样做,并建立使用中间人应用程序

%script{:type => "text/html", :id => "showItem"}
  {{#items}}
  %li
    %a{href: "#{{id}}"} {{showName}}
  {{/items}}
问题是当
{{id}}
在另一个
{}
中时,这一行
%a{href:“{{id}}}

这里是错误

SyntaxError at /show.html
/show.haml:110: syntax error, unexpected '}', expecting tASSOC ...tributes({}, nil, href: "#{{id}}")}>{{showName}}</a>\n ... ... ^ /show.haml:127: syntax error, unexpected ',', expecting '}' ...script>\n </body>\n</html>\n", -2, false); ... ^ /show.haml:131: syntax error, unexpected keyword_end, expecting '}'

Ruby    C:/Ruby193/lib/ruby/gems/1.9.1/gems/tilt-1.3.3/lib/tilt/template.rb: in instance_eval, line 209
Web GET localhost/show.html
SyntaxError位于/show.html
/show.haml:110:语法错误,意外“}”,应为tASSOC…属性({},nil,href:“{{{id}”)}>{{showName}\n……^/show.haml:127:语法错误,意外“,”,应为“}”…脚本>\n\n\n“,-2,false);…^/show.haml:131:语法错误,意外关键字_end,应为“}”
Ruby C:/Ruby193/lib/Ruby/gems/1.9.1/gems/tilt-1.3.3/lib/tilt/template.rb:在实例中,第209行
Web GET localhost/show.html
有没有办法解决这个问题?因为我需要使用手柄来解析标签属性中的变量

谢谢。

Haml将
{{id}}
作为字符串插值进行计算。因此它将外部
{…}
视为要计算的Ruby代码的容器(就像任何标准Ruby代码一样),因此它尝试在Ruby中计算
{id}

Ruby看到了
id
周围的大括号,并期望得到一个散列,这就是为什么会出现“unexpected'}'”错误

解决方案是转义
#
以避免字符串插值:

%a{href: "\#{{id}}"} {{showName}}