Skip to content

Commit

Permalink
Release v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kate2753 committed Feb 20, 2014
1 parent c383b44 commit 0321118
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 22 deletions.
Binary file added archive/dustjs-helpers-1.2.0.tar.gz
Binary file not shown.
Binary file added archive/dustjs-helpers-1.2.0.zip
Binary file not shown.
46 changes: 27 additions & 19 deletions dist/dust-helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! dustjs-helpers - v1.1.2
/*! dustjs-helpers - v1.2.0
* https://github.com/linkedin/dustjs-helpers
* Copyright (c) 2014 Aleksander Williams; Released under the MIT License */
(function(dust){
Expand Down Expand Up @@ -117,26 +117,34 @@ var helpers = {
dust render emits < and we return the partial output
*/
"tap": function( input, chunk, context ){
"tap": function(input, chunk, context) {
// return given input if there is no dust reference to resolve
var output = input;
// dust compiles a string/reference such as {foo} to function,
if( typeof input === "function"){
// just a plain function (a.k.a anonymous functions) in the context, not a dust `body` function created by the dust compiler
if( input.isFunction === true ){
output = input();
} else {
output = '';
chunk.tap(function(data){
output += data;
return '';
}).render(input, context).untap();
if( output === '' ){
output = false;
}
}
// dust compiles a string/reference such as {foo} to a function
if (typeof input !== "function") {
return input;
}

var dustBodyOutput = '',
returnValue;

//use chunk render to evaluate output. For simple functions result will be returned from render call,
//for dust body functions result will be output via callback function
returnValue = chunk.tap(function(data) {
dustBodyOutput += data;
return '';
}).render(input, context);

chunk.untap();

//assume it's a simple function call if return result is not a chunk
if (returnValue.constructor !== chunk.constructor) {
//use returnValue as a result of tap
return returnValue;
} else if (dustBodyOutput === '') {
return false;
} else {
return dustBodyOutput;
}
return output;
},

"sep": function(chunk, context, bodies) {
Expand Down
4 changes: 2 additions & 2 deletions dist/dust-helpers.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dustjs-helpers",
"version": "1.1.2",
"version": "1.2.0",
"author": {
"name": "Aleksander Williams",
"url": "http://akdubya.github.com/dustjs"
Expand Down

0 comments on commit 0321118

Please sign in to comment.