精简-如何使一个节点既包含明文又包含其他节点



这是我的瘦身模板:

  h5
    span built by
      a href='http://maxpleaner.com' maxpleaner
      | with
      a a href='http://github.com/maxpleaner/static' static

我期待这个渲染这个:

由maxpleaner用static

构建

但是它呈现的是这个:

由一个href='http://maxpleaner.com' maxpleaner |与一个href='http://github.com/maxpleaner/static' static构建

是否有一种方法来混合明文和子节点,或者我需要使子节点包含我的明文?

如果您以与标签同一行的文本开始,Slim认为整个嵌套块都是纯文本。如果你把" built by "移到block中它会像你想的那样工作:

h5
  span
    | built by 
    a href='http://maxpleaner.com' maxpleaner
    |  with 
    a href='http://github.com/maxpleaner/static' static

你必须小心这里的空格。您可能更喜欢使用'而不是|,并在标签中添加>:

h5
  span
    ' built by
    a> href='http://maxpleaner.com' maxpleaner
    ' with
    a href='http://github.com/maxpleaner/static' static

为了避免空白问题,您可以使用像markdown这样的嵌入式语言,但是这会添加p标记,因此在这种情况下可能不理想:

h5: span
  markdown:
    built by [maxpleaner](http://maxpleaner.com) with [static](http://github.com/maxpleaner/static)

最新更新