Created
April 14, 2010 03:00
-
-
Save raycmorgan/365394 to your computer and use it in GitHub Desktop.
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
/* | |
* hookio/protocols/mustache | |
* Implements a mustache protocol for parsing mustache tags out of text | |
*/ | |
var hookIO = require('../../hookio').hookIO, | |
mu = require('../lib/mu/lib/mu'); | |
exports.start = function() { | |
// little test case | |
var stream = parse('hello this is a template named {tName}',{"tName":"updog"}); | |
stream.addListener('data', function (data) { | |
hookIO.debug(data); | |
}); | |
}; | |
// parse() will perform a sync render with no stream. it is not advised to use this for large blocks of text | |
// or operations that run outside of startup | |
var parse = exports.parse = function(textWithMustaches, dataToMerge){ | |
return mu.compileText(textWithMustaches, {})(dataToMerge); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment