Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mu2

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mu2 - npm Package Compare versions

Comparing version 0.5.3 to 0.5.4

46

lib/mu.js

@@ -133,3 +133,41 @@ var sys = require('sys'),

/**
* Clears all of the cache or a specific template.
*
* @param templateName String If provided only that template is removed from
* the cache, else everything is.
*/
mu.clearCache = function (templateName) {
if (name) {
delete mu.cache[templateName];
} else {
mu.cache = {};
}
};
/**
* Compiles the template and then renders it. Uses the cache if it
* is available.
*
* @param templateName String The name of the template to render
* @param view Object The view object to inject into the template upon render
* @returns Stream THe output stream
*/
mu.compileAndRender = function (templateName, view) {
var stream = new Stream();
var parsed = mu.cache[templateName];
if (parsed) {
beginRenderWithStream(parsed[0].tokens, view, mu.cache, stream);
} else {
mu.compile(templateName, function (err, parsed) {
if (err) return stream.emit('error', err);
beginRenderWithStream(parsed[0].tokens, view, mu.cache, stream);
});
}
return stream;
};
/// Private API

@@ -139,4 +177,10 @@

function beginRender(tokens, view, partials) {
var stream = new Stream();
beginRenderWithStream(tokens, view, partials, stream);
return stream;
}
function beginRenderWithStream(tokens, view, partials, stream) {
var count = 0;

@@ -153,4 +197,2 @@

});
return stream;
}

@@ -157,0 +199,0 @@

4

package.json
{ "name": "mu2"
, "description": "A Mustache template engine for Node.js"
, "keywords": ["template", "mustache"]
, "version" : "0.5.3"
, "version" : "0.5.4"
, "homepage": "http://github.com/raycmorgan/mu"
, "author" : "RayMorgan <ray@simple-apps.com>"
, "author" : "RayMorgan <ray@rumgr.com>"
, "main" : "lib/mu"
}

@@ -25,3 +25,17 @@ var assert = require('assert'),

].forEach(function (name) {
var js = fs.readFileSync(path.join(mu.root, name + '.js')).toString(),
text = fs.readFileSync(path.join(mu.root, name + '.txt')).toString();
js = eval('(' + js + ')');
var buffer = '';
mu.compileAndRender(name + '.html', js)
.on('data', function (c) { buffer += c.toString(); })
.on('end', function () {
assert.equal(buffer, text);
console.log(name + ' passed');
})
/*
var js = fs.readFileSync(path.join(mu.root, name + '.js')).toString(),

@@ -49,2 +63,3 @@ text = fs.readFileSync(path.join(mu.root, name + '.txt')).toString();

});
*/
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc