Last active
December 28, 2015 21:59
-
-
Save eyy/7568082 to your computer and use it in GitHub Desktop.
mongoose.findOne directly from dust.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | |
| }); | |
| }); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {@mon name="page"} | |
| Hello {title} | |
| {/mon} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment