2011-05-07 100 views
2

嗨,我是scalate/scaml总Noob(我标记为haml,因为scaml & haml很相似)。我有一些模板,看起来像这样:scaml“非法嵌套”错误

[email protected] var customer : com.x.model.Customer 
!!! 
%html 
    %body 
     %p Contact: 
      %a{:href => 'mailto:#{customer.email}'}=customer.contact 

在%p线标记有此错误:

org.fusesource.scalate.InvalidSyntaxException: Illegal nesting: content can't be given on the same line as html element or nested within it if the tag is closed at 16.17 
+0

当我从%p行删除“Contact:”时,它会使其进一步......变成其他语法错误。但我不明白我为什么做错了。我想要的HTML是

联系人:xxxx

Kevin 2011-05-07 02:23:58

+0

把“联系人:”在%跨度似乎是一种解决方法... – Kevin 2011-05-07 02:30:25

回答

5

在HAML,你不能提供在同一行和缩进内容两者。

所以,如果你写%p Contact:,你不能添加任何东西到<p>。您必须将所有内容移动到下一个缩进级别:

%p 
     Contact: 
     %a{:href => 'mailto:#{customer.email}'}=customer.contact 
+0

感谢您的答案! – Kevin 2011-05-07 18:29:22