Skip to content

Instantly share code, notes, and snippets.

@raycmorgan
Created April 14, 2010 03:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raycmorgan/365394 to your computer and use it in GitHub Desktop.
Save raycmorgan/365394 to your computer and use it in GitHub Desktop.
/*
* 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