json - In "for article, slug in public.articles._data" what is "slug"? Is there a way to use nesting arrays? -


i experiment harpjs, nodejs static blog generator. in tutorials there such example metadata:

for article, slug in public.articles._data  a(href="/articles/#{ slug }")   h2= article.title 

and _data.json file:

{  "hello-world": {  <-- available everywhere public.articles._data   "title": "hello world.",   "date": "2013-02-28"  },  "hello-brazil": {   "title": "hello brazil.",   "date": "2013-03-04"  } } 

if understand right for article takes every high level object , can title article.title or date article.date. slug? predefined variable in jade/harpjs? if so, there others, or did concept wrong? couldn't find information on topic, if there article read appreciate it. thank you.

as @brennan suggests in comments second argument index. simple substitution , renaming of variables article , slug proves that. there 1 more problem. please consider example:

{  "hello-world": {   "title": "hello world.",   "date": "2013-02-28",   "test": {     "testcontent": "123"   }  },  "hello-brazil": {   "title": "hello brazil.",   "date": "2013-03-04"  } }   s, in public.articles._data  a(href="/articles/#{ }")   h2= s.title   h3= s.date   h3=   - var obj =  s.test   h3= obj   h3= obj.testcontent 

this code gives error during compilation. if comment last line works though. , can't substitute last line snippet docs:

each val, index in obj   h1=index + ': ' + val 

there no nesting , two-dimensional arrays?

to answer original question see comment:

the documentation lacking. i'm not totally convinced work. according jade supports each , while constructs. in other languages, 2nd argument in for..in loop index. it's possible that's case here, can't find concrete documentation

the second question issue mock object.

looks need check sure property defined in mockdata, or checking sure property expect, exists.


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -