node.js, express, consolidate, dustjs-linkedin AND dustjs-helpers

i just started playing with node.js and so far it seems pretty intriguing. my first use case for node.js is to make some JSON APIs. trying to figure out what the structure of a node.js project should be has been a pretty frustrating experience, though.

nevermind that node.js is still in its infancy and the core APIs have been changing at an alarming rate.

nevermind that this means that many blogs that you read about node.js examples won’t work anymore because they were for an older version of node.

what is the most frustrating thing in the world is that trying to figure out what best practice is seems impossible to verify because everyone is still trying to figure out what best practice really is.

that being said, i’ve decided to use express as the web framework. it seems pretty popular, lightweight, and relatively straightforward to use.

i wanted to be able to use a javascript template engine and though there are many, many options out there, i’ve decided to use the linked fork of dust.js. the linkedin guys seem to have a pretty good thing going there and have made some improvements to the engine that really help.

a convenience layer is consolidate which will make swapping template engines relatively painless, though in practice, i don’t know how realistic this is because even though you can swap out a template engine, the views probably won’t be syntactically compatible. still, using consolidate did make setting up dustjs relatively straightforward.

that being said, IF you use consolidate and you want to use dustjs-helpers, there’s really no good documentation on how to do it. the best hint i found was actually in the git repo for dustjs.

1
2
3
4
    app.engine('dust', cons.dust);
    cons.dust.helpers = require('dustjs-helpers');
    app.set('view engine', 'dust');
    app.set('views', __dirname + '/views');

One thought on “node.js, express, consolidate, dustjs-linkedin AND dustjs-helpers”

  1. Hello admin, i must say you have very interesting content here.
    Your page can go viral. You need initial traffic boost only.
    How to get it? Search for: Mertiso’s tips go viral

Leave a Reply

Your email address will not be published.