Reputation: 787
im working on a site where im using jade for the html. I have a folder which contains 20 ish .html-files.
How can I with jade create a loop that lists all these files on a single page? Eg: list the files names.
Currently I just have a simple for loop which obviously not works.
for (var i = 0; i < 10; ++i) {
li= array[i]
}
Upvotes: 3
Views: 492
Reputation: 3556
In your server (PHP or another language) you can have a URL that respond with a JSON with a list of your html files
Something like this:
http://some.org/listfiles.json
And return something like this:
[
"file1.html",
"file2.html",
"file3.html",
...
]
Then in your Javascript you use ajax to get the json and put it in a variable (For example you can use the library Jquery to get the json http://api.jquery.com/jquery.getjson/ ).
Then in Jade you can iterate throw the list of files.
http://jade-lang.com/reference/iteration/
Upvotes: 1