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.19 to 0.5.20

.npmignore

4

lib/mu/parser.js

@@ -88,5 +88,5 @@ var util = require('util'),

"\\s*" + // Skip any whitespace
"([^(?:\\}?" + e(ctag) + ")]+)" + // Capture the text inside of the tag
"(.+?)" + // Capture the text inside of the tag : non-greedy regex
"\\s*" + // Skip any whitespace
"\\}?" + // Skip balancing '}' if it exists
"=?\\}?" + // Skip balancing '}' or '=' if it exists
e(ctag) + // Find the close of the tag

@@ -93,0 +93,0 @@

@@ -55,7 +55,7 @@ var BUFFER_LENGTH = 1024 * 8;

case 'utag': // Unescaped Tag
stream.emit('data', s(normalize(context, token[2])));
stream.emit('data', s(normalize(context, token[2]),stream,token[2]));
return next();
case 'etag': // Escaped Tag
stream.emit('data', escape(s(normalize(context, token[2]))));
stream.emit('data', escape(s(normalize(context, token[2]),stream,token[2])));
return next();

@@ -100,4 +100,7 @@

function s(val) {
function s(val,stream,token) {
if (val === null || typeof val === 'undefined') {
if(stream && token){
stream.emit('warn',{token:token,category:'token.undefined'});
}
return '';

@@ -104,0 +107,0 @@ } else {

{ "name": "mu2"
, "description": "A Mustache template engine for Node.js"
, "keywords": ["template", "mustache"]
, "version" : "0.5.19"
, "version" : "0.5.20"
, "homepage": "http://github.com/raycmorgan/mu"
, "author" : "RayMorgan <ray@rumgr.com>"
, "main" : "lib/mu"
, "main" : "lib/mu",
"licenses": [
{
"type": "MIT",
"url": "https://raw.github.com/raycmorgan/Mu/master/LICENSE"
}
]
}

@@ -19,46 +19,46 @@ # Mu - a fast, streaming Node.js Mustache engine

There are a few ways to use mu 0.5. Here is the simplest:
```javascript
var mu = require('mu2'); // notice the "2" which matches the npm repo, sorry..
var mu = require('mu2'); // notice the "2" which matches the npm repo, sorry..
mu.root = __dirname + '/templates'
mu.compileAndRender('index.html', {name: "john"})
.on('data', function (data) {
console.log(data.toString());
});
mu.root = __dirname + '/templates'
mu.compileAndRender('index.html', {name: "john"})
.on('data', function (data) {
console.log(data.toString());
});
```
Here is an example mixing it with the http module:
```javascript
var http = require('http')
, util = require('util')
, mu = require('mu2');
var http = require('http')
, util = require('util')
, mu = require('mu2');
mu.root = __dirname + '/templates';
mu.root = __dirname + '/templates';
http.createServer(function (req, res) {
http.createServer(function (req, res) {
var stream = mu.compileAndRender('index.html', {name: "john"});
util.pump(stream, res);
var stream = mu.compileAndRender('index.html', {name: "john"});
util.pump(stream, res);
}).listen(8000);
}).listen(8000);
```
Taking that last example here is a little trick to always compile the templates
in development mode (so the changes are immediately reflected).
```javascript
var http = require('http')
, util = require('util')
, mu = require('mu2');
var http = require('http')
, util = require('util')
, mu = require('mu2');
mu.root = __dirname + '/templates';
mu.root = __dirname + '/templates';
http.createServer(function (req, res) {
http.createServer(function (req, res) {
if (process.env.NODE_ENV == 'DEVELOPMENT') {
mu.clearCache();
}
if (process.env.NODE_ENV == 'DEVELOPMENT') {
mu.clearCache();
}
var stream = mu.compileAndRender('index.html', {name: "john"});
util.pump(stream, res);
var stream = mu.compileAndRender('index.html', {name: "john"});
util.pump(stream, res);
}).listen(8000);
}).listen(8000);
```
## API

@@ -65,0 +65,0 @@

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