Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create table dynamically in jade

How to create dynamic rows for table in jade. My data for rows will be coming from MongoDB rendered by nodejs. Here is my MongoDB document =>

{
    "_id" : ObjectId("55429a92bf0adf38ce82052f"),
    "userid" : "103",
    "projectName" : "Nodejs Project",
    "startDate" : "03/15/2015",
    "endDate" : "05/15/2015",
    "tasks" : [ 
        {
            "taskid" : "5",
            "taskDescription" : "Task 5"
        }, 
        {
            "taskid" : "6",
            "taskDescription" : "Task 6"
        }, 
        {
            "taskid" : "7",
            "taskDescription" : "Task 7"
        }
    ]
}

I want taskDescription values to be disaplayed in rows.

like image 863
Tushar Avatar asked May 01 '15 00:05

Tushar


1 Answers

table
  thead
    tr
      th Description
  tbody
    each task in tasks
      tr
        td=task.taskDescription

For future reference, you can test out your jade templates here.

like image 74
Josh C. Avatar answered Oct 23 '22 06:10

Josh C.