Last active
December 21, 2015 02:28
-
-
Save brandonkelly/6234999 to your computer and use it in GitHub Desktop.
Turn a list of entries into JSON in Craft
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
entries: [ | |
{% for entry in craft.entries.find() %} | |
{ | |
title: "{{ entry.title | e('js') }}", | |
tags: [ | |
{% for tag in entry.myTagsField %} | |
"{{ tag.name | e('js') }}" {% if not loop.last %},{% endif %} | |
{% endfor %} | |
], | |
assets: [ | |
{% for asset in entry.myAssetsField %} | |
"{{ asset.url | e('js') }}" {% if not loop.last %},{% endif %} | |
{% endfor %} | |
] | |
} {% if not loop.last %},{% endif %} | |
{% endfor %} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment