templates
Advanced tools
Comparing version 0.1.16 to 0.1.17
@@ -33,2 +33,3 @@ 'use strict'; | ||
lazy('layouts'); | ||
lazy('dest'); | ||
@@ -345,2 +346,46 @@ // glob/matching utils | ||
/** | ||
* Create a dest function to use on an instance of view. | ||
* Useful in a getter method on `view.dest`. | ||
* | ||
* @param {Object} `view` An instance of View | ||
* @return {Function} Function suitable for `file.dest` in the [dest][] plugin. | ||
*/ | ||
utils.destWrapper = function destWrapper(view) { | ||
if (typeof view._dest === 'function') { | ||
return view._dest; | ||
} | ||
return function (dir, options, cb) { | ||
// when function is called with just the callback | ||
if (typeof dir === 'function' && arguments.length === 1) { | ||
cb = dir; | ||
dir = ''; | ||
options = {}; | ||
} | ||
if (typeof options === 'function') { | ||
cb = options; | ||
options = {}; | ||
} | ||
var opts = utils.extend({ | ||
cwd: view.cwd || process.cwd(), | ||
mode: (view.stat ? view.stat.mode : null), | ||
dirMode: null, | ||
overwrite: true | ||
}, options); | ||
if (view._dest && typeof view._dest === 'string') { | ||
var orig = dir; | ||
dir = function (file) { | ||
file.path = view._dest; | ||
return typeof orig === 'function' ? orig(file) : orig; | ||
}; | ||
} | ||
return utils.dest.normalize(dir, view, opts, cb); | ||
}; | ||
}; | ||
/** | ||
* Rename a file | ||
@@ -347,0 +392,0 @@ */ |
@@ -29,2 +29,3 @@ 'use strict'; | ||
this.define('_content', null); | ||
this.define('_dest', null); | ||
this.isView = true; | ||
@@ -45,2 +46,13 @@ | ||
this.define('dest', { | ||
configurable: true, | ||
enumerable: false, | ||
get: function () { | ||
return utils.destWrapper(this); | ||
}, | ||
set: function (val) { | ||
this._dest = val; | ||
} | ||
}); | ||
this.options = this.options || {}; | ||
@@ -47,0 +59,0 @@ this.locals = this.locals || {}; |
{ | ||
"name": "templates", | ||
"description": "System for creating and managing template collections, and rendering templates with any node.js template engine. Can be used as the basis for creating a static site generator or blog framework.", | ||
"version": "0.1.16", | ||
"version": "0.1.17", | ||
"homepage": "https://github.com/jonschlinkert/templates", | ||
@@ -29,2 +29,3 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"define-property": "^0.2.5", | ||
"dest": "^0.2.1", | ||
"en-route": "^0.7.3", | ||
@@ -31,0 +32,0 @@ "engine-base": "^0.1.2", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76474
2176
27
+ Addeddest@^0.2.1
+ Addedcore-util-is@1.0.3(transitive)
+ Addeddest@0.2.1(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedreadable-stream@2.3.8(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedthrough2@2.0.5(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedxtend@4.0.2(transitive)