开发者

question on haml rendering

开发者 https://www.devze.com 2023-03-31 11:52 出处:网络
I seem to be having a problem with haml. Rails is rendering: %span stuff #div_name moar stuff as <span>stuff</span>

I seem to be having a problem with haml. Rails is rendering:

%span
  stuff
  #div_name
  moar stuff

as

<span>stuff</span>
<div id='div_n开发者_如何学编程ame'></div>
moar stuff

any ideas? why isn't 'moar stuff' inside the span?


Works fine for me:

$ echo '%span\n  stuff\n  #div_name\n  moar stuff' | haml

<span>
  stuff
  <div id='div_name'></div>
  moar stuff
</span>


Try this:

%span
  stuff
#div_name
moar stuff

The span only contains stuff, so you have to undent after stuff, so that other elements are not contained in the span.

You can also write it like this:

%span stuff
#div_name
moar stuff

Which gives exactly this:

<span>stuff</span>
<div id='div_name'></div>
moar stuff
0

精彩评论

暂无评论...
验证码 换一张
取 消