2011-05-07 52 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