苗条 - 文本不被识别为标签

时间:2013-03-28 03:58:20

标签: slim-lang

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>

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

由于

1 个答案:

答案 0 :(得分: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>