在哈姆尔非法筑巢

585*_*nor 2 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}
Run Code Online (Sandbox Code Playgroud)

当我进入时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.

我做错了什么?

mat*_*ins 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}
Run Code Online (Sandbox Code Playgroud)

  • 此外,请注意,如果您正在使用vanilla属性,则可以使用[HTML样式属性](http://haml-lang.com/docs/yardoc/file.HAML_REFERENCE.html#htmlstyle_attributes_)来减轻您的打字负担,例如`%td(宽度= 27高度= 100)`; 每个属性少四个字符!:) (2认同)