Friday 15 January 2010

javascript - creating a table using jade and underscore -



javascript - creating a table using jade and underscore -

i want iterate through json object array , create table using underscore , jade jade template throwing me next error , haven't been able find resources prepare it.

error: /home/kseguy/node_projects/prwrite/views/dashboard/index.jade:69 67| script(type="text/template" ,id="data-table") 68| <% _.each(article,function(article){ %> > 69| tr 70| td <%= article.projectname %> 71| td <%= article.date %> 72| td <%= article.status %> unexpected token "indent" @ parser.parseexpr (/home/kseguy/node_projects/prwrite/node_modules/jade/lib/parser.js:252:15) @ parser.block (/home/kseguy/node_projects/prwrite/node_modules/jade/lib/parser.js:707:25) @ parser.tag (/home/kseguy/node_projects/prwrite/node_modules/jade/lib/parser.js:816:24) @ parser.parsetag (/home/kseguy/node_projects/prwrite/node_modules/jade/lib/parser.js:737:17) @ parser.parseexpr (/home/kseguy/node_projects/prwrite/node_modules/jade/lib/parser.js:211:21) @ parser.block (/home/kseguy/node_projects/prwrite/node_modules/jade/lib/parser.js:707:25) @ parser.tag (/home/kseguy/node_projects/prwrite/node_modules/jade/lib/parser.js:816:24) @ parser.parsetag (/home/kseguy/node_projects/prwrite/node_modules/jade/lib/parser.js:737:17) @ parser.parseexpr (/home/kseguy/node_projects/prwrite/node_modules/jade/lib/parser.js:211:21) @ parser.block (/home/kseguy/node_projects/prwrite/node_modules/jade/lib/parser.js:707:25)

how can debug issue ? have tried converting indentation tabs , spaces using sublime text far no success.

here jade template

tbody script(type="text/template" ,id="data-table") <% _.each(article,function(article){ %> tr td <%= article.projectname %> td <%= article.date %> td <%= article.status %> td <%= article.url %> <% }); %>

this work since jade treats things starting < regular text. must careful not possible them have children, lines beneath them can not farther indented.

here jade test normal comments, replace underscore

// http://jsfiddle.net/smwpvngc/2/ <template> script <!-- each --> tr td <!-- col1 --> td <!-- col2 --> td <!-- col3 --> <!-- close each --> </template>

output:

<script> <!-- each --> <tr><td><!-- col1 --></td><td><!-- col2 --></td> <td><!-- col3 --></td></tr><!-- close each --></script>

if add together additional space before tr, indent error jade not know how fill raw entry children.

javascript underscore.js jade

No comments:

Post a Comment