Stacey doesn’t make too many assumptions about which format your templates are written in. It uses the extension of the template file to work out what type of content it should be serving. By default Stacey will recognize and serve the correct content-types for .html, .json, .xml, .atom, .rss, .rdf and .txt files.
In fact, this is how the default RSS feed is built. The /content/feed directory is just a normal Stacey page, the only difference is that it uses .atom rather than .html template files.
So, if you wanted to switch out Atom for the RSS2 format, your /templates/feed.atom template could be renamed to feed.rss and changed to look something like this:
<?xml version="1.0" encoding="utf-8"?> <rss version="2.0"> <channel> <title>{{ page.name }}'s {{ page.feed_name }}</title> <link>http://{{ page.base_url }}/{{ page.permalink }}/</link> <description>{{ page.description }}</description> {% include 'partials/feed/feed_loop.rss' %} </channel> </rss>
Additionally, if clean URLs are enabled, Stacey creates file extension shortcuts for all the file types listed above. This means rather than having to point to http://yourdomain.com/feed/, you could shortcut this to http://yourdomain.com/feed.atom.
Cleaning JSON
Stacey will also automatically compress and strip any trailing commas from JSON templates. So, the following template:
{% set page = get('/') %} { "pages": [ {% for child in page.children %} { "title": "{{ child.page_name }}" }, {% endfor %} ] }
will render as:
{"pages":[{"title":"Projects"},{"title":"About"},{"title":"Contact Me"}]}