Skip to content

Commit

Permalink
Release v2.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Prayrit Jain committed Nov 4, 2014
1 parent af1d01d commit d92d5c3
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 35 deletions.
Binary file added archive/dust-2.5.0.tar.gz
Binary file not shown.
Binary file added archive/dust-2.5.0.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dustjs-linkedin",
"version": "2.4.2",
"version": "2.5.0",
"main": "dist/dust-full.min.js",
"devDependencies": {
"pegjs": "0.8.0"
Expand Down
39 changes: 33 additions & 6 deletions dist/dust-core.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Dust - Asynchronous Templating - v2.4.2
/*! Dust - Asynchronous Templating - v2.5.0
* http://linkedin.github.io/dustjs/
* Copyright (c) 2014 Aleksander Williams; Released under the MIT License */
(function(root) {
Expand All @@ -16,6 +16,25 @@

dust.debugLevel = NONE;

dust.config = {
whitespace: false,
};

// Directive aliases to minify code
dust._aliases = {
"write": "w",
"end": "e",
"map": "m",
"render": "r",
"reference": "f",
"section": "s",
"exists": "x",
"notexists": "nx",
"block": "b",
"partial": "p",
"helper": "h"
};

// Try to find the console in global scope
if (root && root.console && root.console.log) {
loggerContext = root.console;
Expand Down Expand Up @@ -297,7 +316,7 @@
Context.prototype._get = function(cur, down) {
var ctx = this.stack,
i = 1,
value, first, len, ctxThis;
value, first, len, ctxThis, fn;
first = down[0];
len = down.length;

Expand Down Expand Up @@ -342,14 +361,16 @@

// Return the ctx or a function wrapping the application of the context.
if (typeof ctx === 'function') {
return function() {
fn = function() {
try {
return ctx.apply(ctxThis, arguments);
} catch (err) {
dust.log(err, ERROR);
throw err;
}
};
fn.__dustBody = !!ctx.__dustBody;
return fn;
} else {
if (ctx === undefined) {
dust.log('Cannot find the value for reference [{' + down.join('.') + '}] in template [' + this.getTemplateName() + ']');
Expand Down Expand Up @@ -499,7 +520,6 @@
this.events = {};
}
if (!this.events[type]) {
dust.log('Event type [' + type + '] does not exist. Using just the specified callback.', WARN);
if(callback) {
this.events[type] = callback;
} else {
Expand Down Expand Up @@ -612,7 +632,7 @@

Chunk.prototype.section = function(elem, context, bodies, params) {
// anonymous functions
if (typeof elem === 'function') {
if (typeof elem === 'function' && !elem.__dustBody) {
try {
elem = elem.apply(context.current(), [this, context, bodies, params]);
} catch(e) {
Expand Down Expand Up @@ -797,6 +817,13 @@
return this;
};

// Chunk aliases
for(var f in Chunk.prototype) {
if(dust._aliases[f]) {
Chunk.prototype[dust._aliases[f]] = Chunk.prototype[f];
}
}

function Tap(head, tail) {
this.head = head;
this.tail = tail;
Expand All @@ -816,7 +843,7 @@
return value;
};

var HCHARS = new RegExp(/[&<>\"\']/),
var HCHARS = /[&<>"']/,
AMP = /&/g,
LT = /</g,
GT = />/g,
Expand Down
4 changes: 2 additions & 2 deletions dist/dust-core.min.js

Large diffs are not rendered by default.

75 changes: 53 additions & 22 deletions dist/dust-full.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Dust - Asynchronous Templating - v2.4.2
/*! Dust - Asynchronous Templating - v2.5.0
* http://linkedin.github.io/dustjs/
* Copyright (c) 2014 Aleksander Williams; Released under the MIT License */
(function(root) {
Expand All @@ -16,6 +16,25 @@

dust.debugLevel = NONE;

dust.config = {
whitespace: false,
};

// Directive aliases to minify code
dust._aliases = {
"write": "w",
"end": "e",
"map": "m",
"render": "r",
"reference": "f",
"section": "s",
"exists": "x",
"notexists": "nx",
"block": "b",
"partial": "p",
"helper": "h"
};

// Try to find the console in global scope
if (root && root.console && root.console.log) {
loggerContext = root.console;
Expand Down Expand Up @@ -297,7 +316,7 @@
Context.prototype._get = function(cur, down) {
var ctx = this.stack,
i = 1,
value, first, len, ctxThis;
value, first, len, ctxThis, fn;
first = down[0];
len = down.length;

Expand Down Expand Up @@ -342,14 +361,16 @@

// Return the ctx or a function wrapping the application of the context.
if (typeof ctx === 'function') {
return function() {
fn = function() {
try {
return ctx.apply(ctxThis, arguments);
} catch (err) {
dust.log(err, ERROR);
throw err;
}
};
fn.__dustBody = !!ctx.__dustBody;
return fn;
} else {
if (ctx === undefined) {
dust.log('Cannot find the value for reference [{' + down.join('.') + '}] in template [' + this.getTemplateName() + ']');
Expand Down Expand Up @@ -499,7 +520,6 @@
this.events = {};
}
if (!this.events[type]) {
dust.log('Event type [' + type + '] does not exist. Using just the specified callback.', WARN);
if(callback) {
this.events[type] = callback;
} else {
Expand Down Expand Up @@ -612,7 +632,7 @@

Chunk.prototype.section = function(elem, context, bodies, params) {
// anonymous functions
if (typeof elem === 'function') {
if (typeof elem === 'function' && !elem.__dustBody) {
try {
elem = elem.apply(context.current(), [this, context, bodies, params]);
} catch(e) {
Expand Down Expand Up @@ -797,6 +817,13 @@
return this;
};

// Chunk aliases
for(var f in Chunk.prototype) {
if(dust._aliases[f]) {
Chunk.prototype[dust._aliases[f]] = Chunk.prototype[f];
}
}

function Tap(head, tail) {
this.head = head;
this.tail = tail;
Expand All @@ -816,7 +843,7 @@
return value;
};

var HCHARS = new RegExp(/[&<>\"\']/),
var HCHARS = /[&<>"']/,
AMP = /&/g,
LT = /</g,
GT = />/g,
Expand Down Expand Up @@ -3546,7 +3573,7 @@
var compiler = {},
isArray = dust.isArray;


compiler.compile = function(source, name) {
// the name parameter is optional.
// this can happen for templates that are rendered immediately (renderSource which calls compileFn) or
Expand All @@ -3556,7 +3583,7 @@
if (!name && name !== null) {
throw new Error('Template name parameter cannot be undefined when calling dust.compile');
}

try {
var ast = filterAST(parse(source));
return compile(ast, name);
Expand All @@ -3583,7 +3610,7 @@
body: compactBuffers,
buffer: noop,
special: convertSpecial,
format: nullify, // TODO: convert format
format: format,
reference: visit,
'#': visit,
'?': visit,
Expand Down Expand Up @@ -3640,9 +3667,10 @@
for (i=1, len=node.length; i<len; i++) {
res = compiler.filterNode(context, node[i]);
if (res) {
if (res[0] === 'buffer') {
if (res[0] === 'buffer' || res[0] === 'format') {
if (memo) {
memo[1] += res[1];
memo[0] = (res[0] === 'buffer') ? 'buffer' : memo[0];
memo[1] += res.slice(1, -2).join('');
} else {
memo = res;
out.push(res);
Expand All @@ -3665,7 +3693,7 @@
};

function convertSpecial(context, node) {
return ['buffer', specialChars[node[1]]];
return ['buffer', specialChars[node[1]], node[2], node[3]];
}

function noop(context, node) {
Expand All @@ -3674,6 +3702,10 @@

function nullify(){}

function format(context, node) {
return dust.config.whitespace ? node : null;
}

function compile(ast, name) {
var context = {
name: name,
Expand Down Expand Up @@ -3716,7 +3748,7 @@

for (i=0, len=bodies.length; i<len; i++) {
out[i] = 'function body_' + i + '(chk,ctx){' +
blx + 'return chk' + bodies[i] + ';}';
blx + 'return chk' + bodies[i] + ';}body_' + i + '.__dustBody=!0;';
}
return out.join('');
}
Expand All @@ -3743,15 +3775,15 @@
},

buffer: function(context, node) {
return '.write(' + escape(node[1]) + ')';
return '.w(' + escape(node[1]) + ')';
},

format: function(context, node) {
return '.write(' + escape(node[1] + node[2]) + ')';
return '.w(' + escape(node[1] + node[2]) + ')';
},

reference: function(context, node) {
return '.reference(' + compiler.compileNode(context, node[1]) +
return '.f(' + compiler.compileNode(context, node[1]) +
',ctx,' + compiler.compileNode(context, node[2]) + ')';
},

Expand Down Expand Up @@ -3798,7 +3830,7 @@
},

'@': function(context, node) {
return '.helper(' +
return '.h(' +
escape(node[1].text) +
',' + compiler.compileNode(context, node[2]) + ',' +
compiler.compileNode(context, node[4]) + ',' +
Expand Down Expand Up @@ -3838,7 +3870,7 @@
},

partial: function(context, node) {
return '.partial(' +
return '.p(' +
compiler.compileNode(context, node[1]) +
',' + compiler.compileNode(context, node[2]) +
',' + compiler.compileNode(context, node[3]) + ')';
Expand Down Expand Up @@ -3907,12 +3939,12 @@
return escape(node[1]);
},
raw: function(context, node) {
return ".write(" + escape(node[1]) + ")";
return ".w(" + escape(node[1]) + ")";
}
};

function compileSection(context, node, cmd) {
return '.' + cmd + '(' +
return '.' + (dust._aliases[cmd] || cmd) + '(' +
compiler.compileNode(context, node[1]) +
',' + compiler.compileNode(context, node[2]) + ',' +
compiler.compileNode(context, node[4]) + ',' +
Expand Down Expand Up @@ -3946,8 +3978,7 @@
dust.pragmas = compiler.pragmas;
dust.compileNode = compiler.compileNode;
dust.nodes = compiler.nodes;

return compiler;

}));

6 changes: 3 additions & 3 deletions dist/dust-full.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "dustjs-linkedin",
"title": "Dust - Asynchronous Templating",
"version": "2.4.2",
"version": "2.5.0",
"author": {
"name": "Aleksander Williams",
"url": "http://akdubya.github.com/dustjs"
Expand Down

0 comments on commit d92d5c3

Please sign in to comment.