gulp-processhtml
Advanced tools
| var through = require('through2'), | ||
| gutil = require('gulp-util'), | ||
| path = require('path'), | ||
| HTMLProcessor = require('htmlprocessor'), | ||
| PluginError = gutil.PluginError; | ||
| module.exports = function(options) { | ||
| options = options || {}; | ||
| if (!options.customBlockTypes) { | ||
| options.customBlockTypes = []; | ||
| } | ||
| // Add some custom block types. | ||
| options.customBlockTypes.push(path.join(__dirname, 'custom/replace.js')); | ||
| var processor = new HTMLProcessor(options), | ||
| content = ''; | ||
| function processContent(file, enc, cb) { | ||
| if (file.isStream()) { | ||
| this.emit('error', new PluginError('gulp-processhtml', 'Streams aren\'t supported')); | ||
| return cb(); | ||
| } | ||
| if (file.isBuffer()) { | ||
| content = processor.processContent(file.contents.toString(enc), file.path); | ||
| if (options && options.process) { | ||
| content = processor.template(content, processor.data, options.templateSettings); | ||
| } | ||
| file.contents = new Buffer(content, enc); | ||
| } | ||
| this.push(file); | ||
| cb(); | ||
| } | ||
| return through.obj(processContent); | ||
| }; |
| var through = require('through2'), | ||
| PluginError = require('plugin-error'), | ||
| path = require('path'), | ||
| HTMLProcessor = require('htmlprocessor'); | ||
| module.exports = function(options) { | ||
| options = options || {}; | ||
| if (!options.customBlockTypes) { | ||
| options.customBlockTypes = []; | ||
| } | ||
| // Add some custom block types. | ||
| options.customBlockTypes.push(path.join(__dirname, 'custom/replace.js')); | ||
| var processor = new HTMLProcessor(options), | ||
| content = ''; | ||
| function processContent(file, enc, cb) { | ||
| if (file.isStream()) { | ||
| this.emit('error', new PluginError('gulp-processhtml', 'Streams aren\'t supported')); | ||
| return cb(); | ||
| } | ||
| if (file.isBuffer()) { | ||
| content = processor.processContent(file.contents.toString(enc), file.path); | ||
| if (options && options.process) { | ||
| content = processor.template(content, processor.data, options.templateSettings); | ||
| } | ||
| file.contents = new Buffer(content, enc); | ||
| } | ||
| this.push(file); | ||
| cb(); | ||
| } | ||
| return through.obj(processContent); | ||
| }; |
| # gulp-processhtml | ||
| Gulp plugin uses Denis Ciccale's [node-htmlprocessor](https://github.com/dciccale/node-htmlprocessor) | ||
| to process/transform html files. | ||
|  | ||
| | ||
|  | ||
| | ||
|  | ||
| * **npm:** `npm install gulp-processhtml --save-dev` | ||
| ## Gulpfile | ||
| ```js | ||
| var gulp = require('gulp'), | ||
| processhtml = require('gulp-processhtml') | ||
| opts = { /* plugin options */ }; | ||
| gulp.task('default', function () { | ||
| return gulp.src('./*.html') | ||
| .pipe(processhtml(opts)) | ||
| .pipe(gulp.dest('dist')); | ||
| }); | ||
| ``` | ||
| ## Example Usage | ||
| You might need to change some attributes in your html, when you're releasing | ||
| for a different environment. | ||
| Using this plugin, you can transform this: | ||
| ```html | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <!-- build:css style.min.css --> | ||
| <link rel="stylesheet" href="css/style.css"> | ||
| <!-- /build --> | ||
| </head> | ||
| <body> | ||
| <!-- build:js app.min.js --> | ||
| <script src="app.js"></script> | ||
| <!-- /build --> | ||
| <!-- build:remove --> | ||
| <script src="http://192.168.0.1:35729/livereload.js?snipver=1"></script> | ||
| <!-- /build --> | ||
| <!-- build:replace 'Goodbye Livereload...' --> | ||
| <script src="http://192.168.0.1:35729/livereload.js?snipver=1"></script> | ||
| <!-- /build --> | ||
| </body> | ||
| </html> | ||
| ``` | ||
| To this: | ||
| ```html | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <link rel="stylesheet" href="style.min.css"> | ||
| </head> | ||
| <body> | ||
| <script src="app.min.js"></script> | ||
| Goodbye Livereload... | ||
| </body> | ||
| </html> | ||
| ``` | ||
| ## Credits | ||
| [Denis Ciccale](https://twitter.com/dciccale) |
| # gulp-processhtml | ||
| Gulp plugin uses Denis Ciccale's [node-htmlprocessor](https://github.com/dciccale/node-htmlprocessor) | ||
| to process/transform html files. | ||
|  | ||
| | ||
|  | ||
| | ||
|  | ||
| * **npm:** `npm install gulp-processhtml --save-dev` | ||
| ## Gulpfile | ||
| ```js | ||
| var gulp = require('gulp'), | ||
| processhtml = require('gulp-processhtml') | ||
| opts = { /* plugin options */ }; | ||
| gulp.task('default', function () { | ||
| return gulp.src('./*.html') | ||
| .pipe(processhtml(opts)) | ||
| .pipe(gulp.dest('dist')); | ||
| }); | ||
| ``` | ||
| ## Example Usage | ||
| You might need to change some attributes in your html, when you're releasing | ||
| for a different environment. | ||
| Using this plugin, you can transform this: | ||
| ```html | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <!-- build:css style.min.css --> | ||
| <link rel="stylesheet" href="css/style.css"> | ||
| <!-- /build --> | ||
| </head> | ||
| <body> | ||
| <!-- build:js app.min.js --> | ||
| <script src="app.js"></script> | ||
| <!-- /build --> | ||
| <!-- build:remove --> | ||
| <script src="http://192.168.0.1:35729/livereload.js?snipver=1"></script> | ||
| <!-- /build --> | ||
| <!-- build:replace 'Goodbye Livereload...' --> | ||
| <script src="http://192.168.0.1:35729/livereload.js?snipver=1"></script> | ||
| <!-- /build --> | ||
| </body> | ||
| </html> | ||
| ``` | ||
| To this: | ||
| ```html | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <link rel="stylesheet" href="style.min.css"/> | ||
| </head> | ||
| <body> | ||
| <script src="app.min.js"></script> | ||
| Goodbye Livereload... | ||
| </body> | ||
| </html> | ||
| ``` | ||
| ## Credits | ||
| [Denis Ciccale](https://twitter.com/dciccale) |
| # gulp-processhtml | ||
| Gulp plugin uses Denis Ciccale's [node-htmlprocessor](https://github.com/dciccale/node-htmlprocessor) | ||
| to process/transform html files. | ||
|  | ||
| | ||
|  | ||
| | ||
|  | ||
| * **npm:** `npm install gulp-processhtml --save-dev` | ||
| ## Gulpfile | ||
| ```js | ||
| var gulp = require('gulp'), | ||
| processhtml = require('gulp-processhtml') | ||
| opts = { /* plugin options */ }; | ||
| gulp.task('default', function () { | ||
| return gulp.src('./*.html') | ||
| .pipe(processhtml(opts)) | ||
| .pipe(gulp.dest('dist')); | ||
| }); | ||
| ``` | ||
| ## Example Usage | ||
| You might need to change some attributes in your html, when you're releasing | ||
| for a different environment. | ||
| Using this plugin, you can transform this: | ||
| ```html | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <!-- build:css style.min.css --> | ||
| <link rel="stylesheet" href="css/style.css"> | ||
| <!-- /build --> | ||
| </head> | ||
| <body> | ||
| <!-- build:js app.min.js --> | ||
| <script src="app.js"></script> | ||
| <!-- /build --> | ||
| <!-- build:remove --> | ||
| <script src="http://192.168.0.1:35729/livereload.js?snipver=1"></script> | ||
| <!-- /build --> | ||
| <!-- build:replace 'Goodbye Livereload...' --> | ||
| <script src="http://192.168.0.1:35729/livereload.js?snipver=1"></script> | ||
| <!-- /build --> | ||
| </body> | ||
| </html> | ||
| ``` | ||
| To this: | ||
| ```html | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <link rel="stylesheet" href="style.min.css"> | ||
| </head> | ||
| <body> | ||
| <script src="app.min.js"></script> | ||
| Goodbye Livereload... | ||
| </body> | ||
| </html> | ||
| ``` | ||
| ## Credits | ||
| [Denis Ciccale](https://twitter.com/dciccale) |
| <!doctype html> | ||
| <html> | ||
| <head> | ||
| <link rel="stylesheet" href="style.min.css"/> | ||
| </head> | ||
| <body> | ||
| <script src="app.min.js"></script> | ||
| </body> | ||
| </html> |
| <!doctype html> | ||
| <html> | ||
| <head> | ||
| <link rel="stylesheet" href="style.min.css"> | ||
| </head> | ||
| <body> | ||
| <script src="app.min.js"></script> | ||
| </body> | ||
| </html> |
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <link rel="stylesheet" href="style.min.css"/> | ||
| </head> | ||
| <body> | ||
| <script src="app.min.js"></script> | ||
| Goodbye Livereload... | ||
| </body> | ||
| </html> |
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <link rel="stylesheet" href="style.min.css"> | ||
| </head> | ||
| <body> | ||
| <script src="app.min.js"></script> | ||
| Goodbye Livereload... | ||
| </body> | ||
| </html> |
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <!-- build:css style.min.css --> | ||
| <link rel="stylesheet" href="css/style.css"> | ||
| <!-- /build --> | ||
| </head> | ||
| <body> | ||
| <!-- build:js app.min.js --> | ||
| <script src="app.js"></script> | ||
| <!-- /build --> | ||
| <!-- build:remove --> | ||
| <script src="http://192.168.0.1:35729/livereload.js?snipver=1"></script> | ||
| <!-- /build --> | ||
| <!-- build:replace 'Goodbye Livereload...' --> | ||
| <script src="http://192.168.0.1:35729/livereload.js?snipver=1"></script> | ||
| <!-- /build --> | ||
| </body> | ||
| </html> |
| (function main() { | ||
| var gulp = require('gulp'), | ||
| concat = require('gulp-concat'), | ||
| processhtml = require('../index.js'); | ||
| gulp.task('concat', function() { | ||
| gulp.src('js/*.js').pipe(concat('all.js')).pipe(gulp.dest(__dirname)); | ||
| }); | ||
| gulp.task('processhtml', function() { | ||
| gulp.src('index.html').pipe(processhtml()).pipe(gulp.dest(__dirname)); | ||
| }); | ||
| gulp.task('default', ['concat', 'processhtml']); | ||
| })(); |
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <!-- build:js all.js --> | ||
| <script type="text/javascript" src="js/first.js"></script> | ||
| <script type="text/javascript" src="js/second.js"></script> | ||
| <script type="text/javascript" src="js/third.js"></script> | ||
| <!-- /build --> | ||
| </head> | ||
| <body> | ||
| </body> | ||
| </html> |
| var First = {}; |
| var Second = {}; |
| var Third = {}; |
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <link rel="stylesheet" href="style.min.css"> | ||
| </head> | ||
| <body> | ||
| <script src="app.min.js"></script> | ||
| Goodbye Livereload... | ||
| </body> | ||
| </html> |
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <!-- build:css style.min.css --> | ||
| <link rel="stylesheet" href="css/style.css"> | ||
| <!-- /build --> | ||
| </head> | ||
| <body> | ||
| <!-- build:js app.min.js --> | ||
| <script src="app.js"></script> | ||
| <!-- /build --> | ||
| <!-- build:remove --> | ||
| <script src="http://192.168.0.1:35729/livereload.js?snipver=1"></script> | ||
| <!-- /build --> | ||
| <!-- build:replace 'Goodbye Livereload...' --> | ||
| <script src="http://192.168.0.1:35729/livereload.js?snipver=1"></script> | ||
| <!-- /build --> | ||
| </body> | ||
| </html> |
+2
-3
| var through = require('through2'), | ||
| gutil = require('gulp-util'), | ||
| PluginError = require('plugin-error'), | ||
| path = require('path'), | ||
| HTMLProcessor = require('htmlprocessor'), | ||
| PluginError = gutil.PluginError; | ||
| HTMLProcessor = require('htmlprocessor'); | ||
@@ -7,0 +6,0 @@ module.exports = function(options) { |
+5
-4
| { | ||
| "name": "gulp-processhtml", | ||
| "version": "1.1.0", | ||
| "version": "1.2.0", | ||
| "description": "Process html files at build time to modify them as you wish", | ||
@@ -23,4 +23,4 @@ "repository": { | ||
| "dependencies": { | ||
| "gulp-util": "latest", | ||
| "htmlprocessor": "latest", | ||
| "plugin-error": "~0.1.2", | ||
| "through2": "latest" | ||
@@ -30,2 +30,3 @@ }, | ||
| "gulp": "^3.8.11", | ||
| "gulp-concat": "^2.5.2", | ||
| "gulp-cssmin": "^0.1.6", | ||
@@ -35,3 +36,3 @@ "gulp-mocha": "^2.0.0", | ||
| "request": "^2.53.0", | ||
| "xpath": "0.0.9" | ||
| "xpath": "0.0.22" | ||
| }, | ||
@@ -63,2 +64,2 @@ "author": "Julien Castelain <jcastelain@gmail.com> (http://www.punkscum.org)", | ||
| "license": "MIT" | ||
| } | ||
| } |
+1
-1
@@ -78,2 +78,2 @@ # gulp-processhtml | ||
| [Denis Ciccale](https://twitter.com/tdecs) | ||
| [Denis Ciccale](https://twitter.com/dciccale) |
+4
-0
@@ -52,2 +52,6 @@ 'use strict'; | ||
| it('should parse the example from the readme.md', function (done) { | ||
| process('test/fixtures/readme.html', 'test/expected/readme.html', done); | ||
| }); | ||
| }); |
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
19767
104.63%42
61.54%158
88.1%79
1.28%7
16.67%2
100%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed