在哈姆尔非法筑巢

时间:2011-12-05 20:31:08

标签: haml

这是我的Haml代码:

%html
  %head
  %body
    %table {'width' => 638, 'border' => 0, 'cellpadding' => 0, 'cellspacing' => 0}
      %tr
        %td {'width' => 27, 'height' => 100}
        %td {'width' => 582, 'height' => 100}
        %td {'width' => 29, 'height' => 100}

当我输入haml example.haml example.html时,我收到以下错误:

Syntax error on line 5: Illegal nesting: content can't be both given on the same line as %table and nested within it.

我做错了什么?

2 个答案:

答案 0 :(得分:5)

您需要删除标记和大括号之间的空格,如下所示:

%html
  %head
  %body
    %table{'width' => 638, 'border' => 0, 'cellpadding' => 0, 'cellspacing' => 0}
      %tr
        %td{'width' => 27, 'height' => 100}
        %td{'width' => 582, 'height' => 100}
        %td{'width' => 29, 'height' => 100}

答案 1 :(得分:0)

我想帮助别人避免非法筑巢的情况,如果他们没有意识到他们会像我一样犯错误。

如果您忘记元素中的%

,它会说非法嵌套
p.small
  Some text!! Wow!!!!!!

这将导致非法嵌套错误。别忘了你的%s!

%p.small
  Some text that will actually view without errors, Profit!
相关问题