grunt-processhtml
Advanced tools
Comparing version 0.3.6 to 0.3.7
{ | ||
"name": "grunt-processhtml", | ||
"description": "Process html files at build time to modify them depending on the release environment", | ||
"version": "0.3.6", | ||
"version": "0.3.7", | ||
"homepage": "https://github.com/dciccale/grunt-processhtml", | ||
@@ -32,3 +32,4 @@ "author": { | ||
"dependencies": { | ||
"htmlprocessor": "0.1.8" | ||
"async": "^0.9.0", | ||
"htmlprocessor": "0.1.10" | ||
}, | ||
@@ -35,0 +36,0 @@ "devDependencies": { |
@@ -29,3 +29,3 @@ # grunt-processhtml [![Build Status](https://travis-ci.org/dciccale/grunt-processhtml.png?branch=master)](https://travis-ci.org/dciccale/grunt-processhtml) [![NPM version](https://badge.fury.io/js/grunt-processhtml.png)](http://badge.fury.io/js/grunt-processhtml) | ||
```html | ||
<!-- build:<type>[:target] [value] --> | ||
<!-- build:<type>[:target] [inline] [value] --> | ||
... | ||
@@ -47,6 +47,11 @@ <!-- /build --> | ||
##### inline | ||
This modifier can be used with `js` and `css` types. | ||
If used styles or scripts will be included in the output html file. | ||
##### value | ||
Required for types: `js`, `css`, `include` and `[attr]`. | ||
Optional for types: `remove`, `template`. | ||
Optional for types: `remove`, `template` and `js`, `css` types with `inline` modifier. | ||
@@ -57,3 +62,3 @@ Could be a file name: `script.min.js` or a path if an attribute like `[src]` is specified to keep the original file name intact but replace its path. | ||
##### `build:js[:targets] <value>` | ||
##### `build:js[:targets] [inline] <value>` | ||
@@ -64,2 +69,4 @@ Replace many script tags into one. | ||
`inline` Optional modifier. | ||
`<value>` Required value: A file path. | ||
@@ -77,4 +84,33 @@ | ||
##### `build:css[:targets] <value>` | ||
You can embed your javascript: | ||
```html | ||
<!-- build:js inline app.min.js --> | ||
<script src="my/lib/path/lib.js"></script> | ||
<script src="my/deep/development/path/script.js"></script> | ||
<!-- /build --> | ||
<!-- changed to --> | ||
<script> | ||
// app.min.js code here | ||
</script> | ||
``` | ||
or | ||
```html | ||
<!-- build:js inline --> | ||
<script src="my/lib/path/lib.js"></script> | ||
<script src="my/deep/development/path/script.js"></script> | ||
<!-- /build --> | ||
<!-- changed to --> | ||
<script> | ||
// my/lib/path/lib.js code here then... | ||
// my/deep/development/path/script.js code goes here | ||
</script> | ||
``` | ||
##### `build:css[:targets] [inline] <value>` | ||
Replace many stylesheet link tags into one. | ||
@@ -84,2 +120,4 @@ | ||
`inline` Optional modifier. | ||
`<value>` Required value: A file path. | ||
@@ -97,2 +135,31 @@ | ||
You can embed your styles like with `js` type above: | ||
```html | ||
<!-- build:css inline --> | ||
<link rel="stylesheet" href="path/to/normalize.css"> | ||
<link rel="stylesheet" href="path/to/main.css"> | ||
<!-- /build --> | ||
<!-- changed to --> | ||
<style> | ||
/* path/to/normalize.css */ | ||
/* path/to/main.css */ | ||
</style> | ||
``` | ||
or | ||
```html | ||
<!-- build:css inline style.min.css --> | ||
<link rel="stylesheet" href="path/to/normalize.css"> | ||
<link rel="stylesheet" href="path/to/main.css"> | ||
<!-- /build --> | ||
<!-- changed to --> | ||
<style> | ||
/* style.min.css */ | ||
</style> | ||
``` | ||
##### `build:<[attr]>[:targets] <value>` | ||
@@ -512,2 +579,3 @@ | ||
## Release History | ||
- 0.3.7 Update [node-htmlprocessor](https://github.com/dciccale/node-htmlprocessor) dependency with added `inline` modifier | ||
- 0.3.6 Update node-htmlprocessor version and add specific test for templates | ||
@@ -514,0 +582,0 @@ - 0.3.5 Fixes issue when passing data to a `template` |
@@ -16,2 +16,3 @@ /* | ||
var path = require('path'); | ||
var async = require('async'); | ||
@@ -31,16 +32,26 @@ grunt.registerMultiTask('processhtml', 'Process html files at build time to modify them depending on the release environment', function () { | ||
var done = this.async(); | ||
var html = new HTMLProcessor(options); | ||
this.files.forEach(function (f) { | ||
var src = f.src.filter(function (filepath) { | ||
async.eachSeries(this.files, function(f, n) { | ||
var destFile = path.normalize(f.dest); | ||
var srcFiles = f.src.filter(function(filepath) { | ||
// Warn on and remove invalid source files (if nonull was set). | ||
if (!grunt.file.exists(filepath)) { | ||
grunt.log.warn('Source file "' + filepath + '" not found.'); | ||
return false; | ||
} else { | ||
return true; | ||
} | ||
}).map(function (filepath) { | ||
var content = html.process(filepath); | ||
return true; | ||
}); | ||
if (srcFiles.length === 0) { | ||
// No src files, goto next target. Warn would have been issued above. | ||
return n(); | ||
} | ||
var result = []; | ||
async.concatSeries(srcFiles, function(file, next) { | ||
var content = html.process(file); | ||
if (options.process) { | ||
@@ -50,9 +61,14 @@ content = html.template(content, html.data, options.templateSettings); | ||
return content; | ||
}).join(grunt.util.linefeed); | ||
result.push(content); | ||
next(null); | ||
grunt.file.write(f.dest, src); | ||
grunt.log.writeln('File "' + f.dest + '" created.'); | ||
}, function() { | ||
grunt.file.write(destFile, result.join(grunt.util.normalizelf(grunt.util.linefeed))); | ||
grunt.verbose.writeln('File ' + destFile.cyan + ' created.'); | ||
n(); | ||
}); | ||
}, function() { | ||
done(); | ||
}); | ||
}); | ||
}; |
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
19286
59
591
3
+ Addedasync@^0.9.0
+ Addedasync@0.9.2(transitive)
+ Addedhtmlprocessor@0.1.10(transitive)
- Removedhtmlprocessor@0.1.8(transitive)
Updatedhtmlprocessor@0.1.10