Skip to content

Instantly share code, notes, and snippets.

@eyy
Last active December 28, 2015 21:59
Show Gist options
  • Select an option

  • Save eyy/7568082 to your computer and use it in GitHub Desktop.

Select an option

Save eyy/7568082 to your computer and use it in GitHub Desktop.
mongoose.findOne directly from dust.js
dust.helpers.mon = function(chunk, ctx, bodies, params) {
return chunk.map(function(chunk) {
var m = params.name;
if (!m || !models[m]) return chunk.write('No such model').end();
models[m].findOne().exec(function(err, doc) {
if (err) return chunk.write(err).end();
chunk.render(bodies.block, ctx.push(doc)).end();
});
});
};
{@mon name="page"}
Hello {title}
{/mon}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment