htmlprocessor
Advanced tools
Comparing version 0.3.2 to 0.3.3
@@ -5,3 +5,3 @@ /* | ||
* | ||
* Copyright (c) 2013-2016 Denis Ciccale (@dciccale) | ||
* Copyright (c) 2013-2023 Denis Ciccale (@dciccale) | ||
* Licensed under the MIT license. | ||
@@ -22,3 +22,5 @@ * https://github.com/dciccale/node-htmlprocessor/blob/master/LICENSE-MIT | ||
if (options && options.customBlockTypes && options.customBlockTypes.length) { | ||
options.customBlockTypes = options.customBlockTypes.map(function (processor) { | ||
options.customBlockTypes = options.customBlockTypes.map(function ( | ||
processor | ||
) { | ||
return path.resolve(processor); | ||
@@ -25,0 +27,0 @@ }); |
@@ -5,3 +5,3 @@ /* | ||
* | ||
* Copyright (c) 2013-2016 Denis Ciccale (@dciccale) | ||
* Copyright (c) 2013-2023 Denis Ciccale (@dciccale) | ||
* Licensed under the MIT license. | ||
@@ -33,3 +33,5 @@ * https://github.com/dciccale/node-htmlprocessor/blob/master/LICENSE-MIT | ||
this.options = utils._.extend({}, defaults, options); | ||
this.data = utils._.extend({}, this.options.data, {environment: this.options.environment}); | ||
this.data = utils._.extend({}, this.options.data, { | ||
environment: this.options.environment | ||
}); | ||
this.parser = new Parser(this.options); | ||
@@ -89,6 +91,9 @@ | ||
blocks.forEach(function (block) { | ||
// Parse through correct block type checking the build environment | ||
if (this._blockTypes[block.type] && (!block.targets || | ||
utils._.indexOf(block.targets, this.options.environment) >= 0) || (!this.options.strip && !this.options.environment)) { | ||
if ( | ||
(this._blockTypes[block.type] && | ||
(!block.targets || | ||
utils._.indexOf(block.targets, this.options.environment) >= 0)) || | ||
(!this.options.strip && !this.options.environment) | ||
) { | ||
result = this._replace(block, result, filePath); | ||
@@ -124,3 +129,3 @@ } else if (this.options.strip) { | ||
// Lodash 2.4 like template function | ||
HTMLProcessor.prototype.template = function(text, data, options) { | ||
HTMLProcessor.prototype.template = function (text, data, options) { | ||
let compiledTemplate = utils._.template(text, options); | ||
@@ -127,0 +132,0 @@ return compiledTemplate(data); |
@@ -5,3 +5,3 @@ /* | ||
* | ||
* Copyright (c) 2013-2016 Denis Ciccale (@dciccale) | ||
* Copyright (c) 2013-2023 Denis Ciccale (@dciccale) | ||
* Licensed under the MIT license. | ||
@@ -36,7 +36,13 @@ * https://github.com/dciccale/node-htmlprocessor/blob/master/LICENSE-MIT | ||
* - value (optional) i.e. script.min.js | ||
*/ | ||
this.regStart = new RegExp('<!--\\s*' + this.options.commentMarker + ':(\\[?[\\w-]+\\]?)(?::([\\w,]+))?(?:\\s*(inline)\\s)?(?:\\s*(scoped)\\s)?(?:\\s*([^\\s]+)\\s*-->)*'); | ||
*/ | ||
this.regStart = new RegExp( | ||
'<!--\\s*' + | ||
this.options.commentMarker + | ||
':(\\[?[\\w-]+\\]?)(?::([\\w,]+))?(?:\\s*(inline)\\s)?(?:\\s*(scoped)\\s)?(?:\\s*([^\\s]+)\\s*-->)*' | ||
); | ||
// <!-- /build --> | ||
this.regEnd = new RegExp('(?:<!--\\s*)*\\/' + this.options.commentMarker + '\\s*-->'); | ||
this.regEnd = new RegExp( | ||
'(?:<!--\\s*)*\\/' + this.options.commentMarker + '\\s*-->' | ||
); | ||
@@ -66,3 +72,3 @@ // <link rel="stylesheet" href="js/bower_components/bootstrap/dist/css/bootstrap.css" /> | ||
block = { | ||
type: attr ? 'attr': build[1], | ||
type: attr ? 'attr' : build[1], | ||
attr: attr, | ||
@@ -97,3 +103,2 @@ targets: !!build[2] ? build[2].split(',') : null, | ||
return sections; | ||
}; | ||
@@ -100,0 +105,0 @@ |
@@ -5,3 +5,3 @@ /* | ||
* | ||
* Copyright (c) 2013-2016 Denis Ciccale (@dciccale) | ||
* Copyright (c) 2013-2023 Denis Ciccale (@dciccale) | ||
* Licensed under the MIT license. | ||
@@ -36,5 +36,5 @@ * https://github.com/dciccale/node-htmlprocessor/blob/master/LICENSE-MIT | ||
if (mode == null) { | ||
mode = parseInt('0777', 8) & (~process.umask()); | ||
mode = parseInt('0777', 8) & ~process.umask(); | ||
} | ||
dirpath.split(/[\/\\]/g).reduce(function(parts, part) { | ||
dirpath.split(/[\/\\]/g).reduce(function (parts, part) { | ||
parts += part + '/'; | ||
@@ -47,3 +47,10 @@ var subpath = path.resolve(parts); | ||
} catch (e) { | ||
throw util.error('Unable to create directory "' + subpath + '" (Error code: ' + e.code + ').', e); | ||
throw util.error( | ||
'Unable to create directory "' + | ||
subpath + | ||
'" (Error code: ' + | ||
e.code + | ||
').', | ||
e | ||
); | ||
} | ||
@@ -50,0 +57,0 @@ } |
{ | ||
"name": "htmlprocessor", | ||
"description": "Process html file using special comments", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"author": { | ||
"name": "Denis Ciccale", | ||
"email": "dciccale@gmail.com", | ||
"url": "http://twitter.com/tdecs" | ||
"url": "http://twitter.com/dciccale" | ||
}, | ||
@@ -47,4 +47,4 @@ "repository": { | ||
"istanbul": "^0.4.5", | ||
"mocha": "^5.2.0" | ||
"mocha": "^10.2.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
24951
17
446