【问题标题】:Socketstream - handling an array with Jade+Hogan templatesSocketstream - 使用 Jade+Hogan 模板处理数组
【发布时间】:2013-07-10 02:26:16
【问题描述】:

我使用 Socketstream 默认堆栈与 Jade 和 ss-hogan 进行模板。我喜欢它,只是我不知道如何打印列表。示例:

client.js

html = ss.tmpl['game-full'].render({
  name: 'GTA IV',
  platforms: [{
      name: 'ps3'
    }, {
      name: 'xbox'
    }
  ]
})

模板/游戏/full.jade

h1 {{name}} is fine
ul
  li I don't know how to list {{platforms}} here, one per li

我只是对 Jade>HTML>Hogan 流程有点困惑,我不知道该使用什么语法。

【问题讨论】:

    标签: javascript node.js pug hogan.js socketstream


    【解决方案1】:

    这里记录了在列表中呈现项目的方式:https://gist.github.com/fat/1484342#file-gistfile1-html

    可以在此处找到 SocketStream 应用程序中的示例:https://github.com/Anephenix/dashku/blob/master/client/templates/dashboard/nav.jade

    看看你的代码,我建议试试这个:

    h1 {{name}} is fine
    ul
      {{#platforms}}
      li I don't know how to list {{name}} here, one per li     
      {{/platforms}}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-17
      • 2012-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-28
      • 1970-01-01
      • 2016-12-13
      相关资源
      最近更新 更多