You can get Jekyll to parse any file by adding an empty foreground element to it.
example: assets / js / script.js
Edit 16/07/28 : you can use jsonify filter for any hash or array
Old answer
--- --- {% capture posts %} [ {% for post in site.posts %} { "title" : "{{ post.title }}", "url" : "{{ post.url }}", "date" : "{{ post.date | date: "%B %d, %Y" }}", "content" : "{{ post.content | escape }}" } {% if forloop.last %}{% else %},{% endif %} {% endfor %} ] {% endcapture %} var posts = {{posts | strip_newlines}}
This will put the collection of site.posts objects in the json form and assign you javascript posts var.
David Jacquel
source share