scaml “illegal nesting” error

2019-07-14 13:42发布

问题:

Hi I'm a total Noob at scalate/scaml (I tagged haml since scaml & haml are similar). I have some template that looks like this:

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

The %p line is flagged with this error:

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

回答1:

In HAML, you can't provide content both on the same line and indented.

So, if you write %p Contact:, you can't add anything else to the <p>. You have to move everything to the next indentation level:

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