骗局"非法嵌套"错误

Kev*_*vin 2 haml scala scalate

嗨,我是scalate/scaml的总Noob(由于scaml和haml相似,我标记了haml).我有一些看起来像这样的模板:

-@ var customer : com.x.model.Customer
!!!
%html
    %body
        %p Contact:
            %a{:href => 'mailto:#{customer.email}'}=customer.contact
Run Code Online (Sandbox Code Playgroud)

%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
Run Code Online (Sandbox Code Playgroud)

Mic*_*ant 5

在HAML中,您无法在同一行和缩进上提供内容.

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

    %p
      Contact:
      %a{:href => 'mailto:#{customer.email}'}=customer.contact
Run Code Online (Sandbox Code Playgroud)