在Jade中有空值以进行适当的布局?

时间:2016-02-25 19:20:17

标签: layout pug

如图所示,我有一个地址字段,如果在两行上看起来最好。在这里显示一个句点(。)使其工作。我可以让Jade有一个" p"内部没有值的标签使双列地址字段正确显示? Layout with period

以下是" p"的代码。有问题的标签位于中间:

.panel.panel-primary
    .panel-heading
      h2.panel-title
        | #{appointment.location} Information
    .panel-body
      p 
        | Distance:
        span.pull-right.badge-default= appointment.distance
      p 
        | Address:
        span.pull-right.badge-default= appointment.address.street
      p.span.pull-right.badge-default= appointment.address.region
      p .     
      p 
        | Phone Number:
        span.pull-right.badge-default= appointment.phoneNumber
      each time in appointment.openingTimes
        p
          | #{time.days}: 
          if time.closed
            span.pull-right.badge-default closed
          else
            span.pull-right.badge-default #{time.opening} - #{time.closing}

没有句号,这就是它的样子: Layout with p tag empty

背后的代码:

.panel.panel-primary
    .panel-heading
      h2.panel-title
        | #{appointment.location} Information
    .panel-body
      p 
        | Distance:
        span.pull-right.badge-default= appointment.distance
      p 
        | Address:
        span.pull-right.badge-default= appointment.address.street
      p.span.pull-right.badge-default= appointment.address.region
      p      
      p 
        | Phone Number:
        span.pull-right.badge-default= appointment.phoneNumber
      each time in appointment.openingTimes
        p
          | #{time.days}: 
          if time.closed
            span.pull-right.badge-default closed
          else
            span.pull-right.badge-default #{time.opening} - #{time.closing}

1 个答案:

答案 0 :(得分:0)

为什么不用点标记来代替带标记的p-tag?或者给p-tag添加第二个地址 - span-margin。

  p 
    | Address:
    span.pull-right.badge-default= appointment.address.street
    br
    span.pull-right.badge-default= appointment.address.region
    br     
  p 
    | Phone Number: