开发者

Dynamic html pages with Jade, NodeJS, Express

开发者 https://www.devze.com 2023-02-15 04:23 出处:网络
I have a big json object containing开发者_开发知识库 cell data from a sample spreadsheet that has been retrieved from redis keystore. I want to show it in a html table format in the jade template. But

I have a big json object containing开发者_开发知识库 cell data from a sample spreadsheet that has been retrieved from redis keystore. I want to show it in a html table format in the jade template. But for now, all I can show it as is a json string.

I am also unclear about how to generate dynamic web pages using jade/express.

Sample JSON string am trying to pass:

{"1A":"Cell Data 1", "1B": "Cell Data 2",...}

It is data from an excel spreadsheet.

Please help me to clear this doubt.


table
  thead
    tr
      th Name
      th Food
  tbody
    - var items = [{name:'Dean',food:'Chicken'}, {name:'Paul',food:'steak'}]
    - each item in items
      tr
        td= item.name
        td= item.food

outputs

<table><thead><tr><th>Name</th><th>Food</th></tr></thead><tbody><tr><td>Dean</td><td>Chicken</td></tr><tr><td>Paul</td><td>steak</td></tr></tbody></table>

or more practically than defining the items array of objects in jade

var items = dynamicallyGenerateYourJson();
res.render('table', {
  items: items
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号