Relisten

I’ve been working on a side project, Relisten.  This is a web application for Facebook and Spotify users that aggregates listening history into weekly playlists that can be “relistened” through Spotify. The app came from my usage of Last.fm and the realization that no such tools exist for data on Facebook.

Relisten was an exercise in using the Facebook javascript API and HTML5 localStorage. The technical goal of Relisten is to achieve a fully functional web application without any server-side processing. Facebook data is retrieved from your own browser and stored locally, allowing for an intrinsically scalable app.

Rendering Trees with Meteor.js + Handlebars

Handlebars is currently the only template engine integrated with Meteor. Notably absent from Handlebar’s feature set is the ability to pass context between blocks. Furthermore, the scope of a parent block is absolutely inaccessible from the child’s context (no super, no this.parent).

One can get around any restriction imposed by Handlebar’s markup by writing a custom block helper. The theory behind block helpers is to keep logic separate from the design markup. Every block in Handlebars (if, each, with, list…) calls a block helper behind the scenes. The block helper is a function which takes the block’s HTML content as an argument, as well as any arguments listed in the block’s declaration, and uses these arguments to return a string which is rendered in place of the block. It’s sort of like a macro.

In the case of a tree, using a block helper is absolutely the way to go.