grunt-html-build
Advanced tools
Comparing version 0.1.4 to 0.1.5
{ | ||
"name": "grunt-html-build", | ||
"description": "Grunt HTML Builder - Appends scripts and styles, Removes debug parts, append html partials, Template options", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"homepage": "https://github.com/spatools/grunt-html-build.git", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -158,2 +158,5 @@ grunt-html-build | ||
* 0.1.1 Cleaning, adding optional tags, using js-beautify | ||
* 0.1.2 Adding expand options to tags paths and write docs | ||
* 0.1.2 Adding expand options to tags paths and write docs | ||
* 0.1.3 Fixing nodejs dependencies | ||
* 0.1.4 Fixing nodejs dependencies | ||
* 0.1.5 Optimize src loop / Fix js-beautify options |
@@ -51,9 +51,9 @@ /* | ||
var lines = content.replace(/\r\n/g, '\n').split(/\n/), | ||
tag = false, | ||
tag = false, | ||
tags = [], | ||
last; | ||
last; | ||
lines.forEach(function (l) { | ||
var tagStart = l.match(regexTagStart), | ||
tagEnd = regexTagEnd.test(l); | ||
tagEnd = regexTagEnd.test(l); | ||
@@ -192,43 +192,46 @@ if (tagStart) { | ||
this.files.forEach(function (file) { | ||
var dest = file.dest || "", | ||
destPath, content, tags; | ||
this.files.forEach(function (file) { | ||
var src = file.src[0], dest = file.dest, | ||
destPath = dest ? path.join(dest, path.basename(src)) : src, | ||
content = grunt.file.read(file.src[0]).toString(), | ||
file.src.forEach(function (src) { | ||
destPath = path.join(dest, path.basename(src)); | ||
content = grunt.file.read(src).toString(); | ||
tags = getBuildTags(content); | ||
tags.forEach(function (tag) { | ||
var raw = tag.lines.join(EOL), | ||
result = "", | ||
tagFiles = validators.validate(tag, params); | ||
tags.forEach(function (tag) { | ||
var raw = tag.lines.join(EOL), | ||
result = "", | ||
tagFiles = validators.validate(tag, params); | ||
if (tagFiles) { | ||
var options = _.extend({}, tag, { | ||
data: _.extend({}, config, params.data), | ||
files: tagFiles, | ||
dest: dest | ||
}); | ||
if (tagFiles) { | ||
var options = _.extend({}, tag, { | ||
data: _.extend({}, config, params.data), | ||
files: tagFiles, | ||
dest: dest | ||
}); | ||
result = processors.transform(options); | ||
result = processors.transform(options); | ||
} | ||
else if (tag.optional) { | ||
if (params.logOptionals) | ||
grunt.log.error().error("Tag with type: '" + tag.type + "' and name: '" + tag.name + "' is not configured in your Gruntfile.js but is set optional, deleting block !"); | ||
} | ||
else { | ||
grunt.fail.warn("Tag with type '" + tag.type + "' and name: '" + tag.name + "' is not configured in your Gruntfile.js !"); | ||
} | ||
content = content.replace(raw, result); | ||
}); | ||
if (params.beautify) { | ||
content = beautify.html(content, _.isObject(params.beautify) ? params.beautify : {}); | ||
} | ||
else if (tag.optional) { | ||
if (params.logOptionals) | ||
grunt.log.error().error("Tag with type: '" + tag.type + "' and name: '" + tag.name + "' is not configured in your Gruntfile.js but is set optional, deleting block !"); | ||
} | ||
else { | ||
grunt.fail.warn("Tag with type '" + tag.type + "' and name: '" + tag.name + "' is not configured in your Gruntfile.js !"); | ||
} | ||
content = content.replace(raw, result); | ||
// write the contents to destination | ||
grunt.file.write(destPath, content); | ||
grunt.log.writeln("File " + destPath + " created !"); | ||
}); | ||
if (params.beautify) { | ||
content = beautify.html(content, _.isObject(beautify) ? beautify : {}); | ||
} | ||
// write the contents to destination | ||
grunt.file.write(destPath, content); | ||
grunt.log.writeln("File " + destPath + " created !"); | ||
}); | ||
}); | ||
}; |
Sorry, the diff of this file is not supported yet
243
161
36150
25