Show HN: Shunter – a Node.js application to read JSON and translate it into HTML
github.comWhat problem does it solve ? is it XSLT for JSON ?
I haven't heard it described like that, but in a sense I guess. At Nature (where it was developed) we use it to decouple our front and back ends. So when we work on a feature we agree on a JSON structure beforehand and work in parallel. It also gives us the ability to work in exactly the same way on the front-end no matter which back-end system is producing the JSON. This is awesome if you're a company that has applications written in quite a few languages
I don't see it solving one problem so much as lots of them.
With a decoupled front-end you can make applications which are much more flexible for dealing with change. Imagine swapping out the entire backend application, or completely re-writing the front-end - you can easily do either since the integration between the two is formalised and documented by the json contracts.
That also means a new front-end developer can clone down a Shunter application and start modifying templates with confidence it's not going to break anything without having to run the backend, services, mock db, etc. Great for working in big teams, or ones that aren't co-located.
It can also run a single unified front-end across multiple backend applications (for example if your rails application wants to share a common layout etc. with your Wordpress-driven blog section, or whatever ecommerce backend is driving your 'shop').
In terms of a concrete example of what we actually use it for, http://www.nature.com/srep/ is using Shunter, as is http://www.nature.com/search?journal=srep&q=physics&subject=. Behind the scenes they're completely different apps, but they use the same implementation of the visual language so there's a consistent UI.
Seems to me that its purpose is to be a server-side pre-renderer for SPAs, i.e. a self-hosted prerender.io.
Might also be cool if you're running a WordPress site and you want the front-end to be an SPA, but you don't want the SEO/page speed hit. Just use WP-API and plug it into Shunter.
After reading the docs, I'm still not quite sure what Shunter does.
I do understand the use scenario. I've done some sites with this same model using Prismic.io as the backend. It's a nice customizable CMS-style system that provides JSON APIs, which a Node.js app then translates into HTML (basically just filling out templates with data selected from the JSON). This has worked well and I've been really quite happy with Prismic.
So it looks like I could be using Shunter for this scenario, but I'm not sure what the benefit would be over my hand-rolled Node apps. Can someone illuminate?
This probably indicates that we need to do a bit of work on our documentation :) You're right about the general purpose - however Shunter also handles front-end assets: images, CSS, and JavaScript, as well as making it easy to extend the rendering engine.
In terms of benefits of using Shunter over a home-rolled solution, the same question could/should be asked of any framework. Shunter is very well tested, has been used in production on a large site for a number of years, and is used to serve hundreds of thousands of requests. It will also be supported by a large development team for the foreseeable future.
Thanks! I'll keep it in mind and will try Shunter next time I do one of the Prismic-backed sites.
Cool - let us know if we can help in any way :)
You put this in the front of your JSON API and BAM don't have to write anything else?
With small changes to the API, it's possible. Shunter requires a certain `Content-Type` header to be sent in order to trigger the rendering process. But largely yes, if your back-end can serve JSON already you should be able to make it play well with Shunter quite easily