Using VIE for server-side templating

In our Palsu collaborative meeting tool we’re using VIE for server-side page generation. This effectively means RDFa is our templating language. The CoffeeScript looks like the following:

# Serve the list of meetings

server.get '/dashboard', (request, response) ->

    # Read our HTML template file

    return fs.readFile "#{process.cwd()}/templates/index.html", "utf-8", (err, data) ->


        # Prepare a JSDOM window for the template

        document = jsdom.jsdom data

        window = document.createWindow()

        jQ = jQuery.create window

        # Find RDFa entities and load them

        VIE.RDFaEntities.getInstances jQ "*"

        # Get the Calendar object

        calendar = VIE.EntityManager.getBySubject 'urn:uuid:e1191010-5bb1-11e0-80e3-0800200c9a66'

        # Query for events that have the calendar as component

        events = calendar.get 'rdfcal:has_component'

        events.predicate = "rdfcal:component"

        events.object =

        return events.fetch

            success: (eventCollection) ->


                return response.send window.document.innerHTML

            error: (collection, error) ->


                return response.send window.document.innerHTML

While this isn’t the most elegant example of page generation with Express, the obvious benefit of RDFa as templating language is there: don’t repeat yourself. The same templating mark-up serves as templating on the server-side, client-side and for SEO and integration purposes.

Read more Decoupled CMS posts.