I experiment with HarpJS, a NodeJS static blog generator. In tutorials there is such example for metadata:
for article, slug in public.articles._data
a(href="/articles/#{ slug }")
h2= article.title
and _data.json
file:
{
"hello-world": { <-- available everywhere as public.articles._data
"title": "Hello World.",
"date": "2013-02-28"
},
"hello-brazil": {
"title": "Hello Brazil.",
"date": "2013-03-04"
}
}
If I understand right for article
takes every high level object and we can get title with article.title
or date with article.date
. But what is slug
? Is it the predefined variable in Jade/HarpJs? If so, are there others, or did I get the concept wrong? I couldn't find any information on this topic, if there is a good article to read I would appreciate it. Thank you.
As @Brennan suggests in comments the second argument could be an index. Simple substitution and renaming of variables article
and slug
proves that. But there is one more problem. Please consider this example:
{
"hello-world": {
"title": "Hello World.",
"date": "2013-02-28",
"test": {
"testContent": "123"
}
},
"hello-brazil": {
"title": "Hello Brazil.",
"date": "2013-03-04"
}
}
for s, a in public.articles._data
a(href="/articles/#{ a }")
h2= s.title
h3= s.date
h3= a
- var obj = s.test
h3= obj
h3= obj.testContent
This code gives error during the compilation. If I comment the very last line it works though. And I can't substitute last line with snippet from the docs:
each val, index in obj
h1=index + ': ' + val
There are no nesting and two-dimensional arrays?