4

Slim 的一个新问题

我期待以下 Slim 模板

div class="header"
h2  slim head 
p a test example of 
    span Slim 
span a new line with span
p 
    | expected a test example of <span>Slim</span>

生成:

<div class="header">
<h2> slim head </h2>
    <p>a test example of <span>Slim</span></p>
    <span>a new line with span</span>
    <p>expected a test example of <span>Slim</span></p>
</div>

但取而代之的是 span 标签未被识别并生成:

<div class="header">
  <h2> slim head </h2>
  <p>a test example of 
         span Slim </p>
  <span>a new line with span</span>
  <p>expected a test example of <span>Slim</span></p>
</div>

为什么跨度被视为文本而不是标签?

谢谢

4

1 回答 1

8

Slim 将您span视为文本,因为您在同一行中开始了段落的实际内容。您应该使用管道 ( |) 嵌套文本并在其后添加跨度,如下所示:

div class="header"
h2  slim head 
p 
    | a test example of 
    span Slim 
span a new line with span
p 
    | expected a test example of <span>Slim</span>

这应该正确编译为:

<div class="header">
  <h2> slim head </h2>
  <p>a test example of <span> Slim</span></p>
  <span>a new line with span</span>
  <p>expected a test example of <span>Slim</span></p>
</div>
于 2013-05-11T07:54:16.237 回答