ghs

gulp-html-sugar

Extendable html syntax sugar plugin

Showing:

Popularity

Downloads/wk

1

GitHub Stars

0

Maintenance

Last Commit

4yrs ago

Contributors

1

Package

Dependencies

4

Size (min+gzip)

72.8KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

gulp-html-sugar

Extendable html syntax sugar Gulp plugin.

Install

Install with npm

npm install gulp-html-sugar --save-dev

Example

gulpfile.js

const htmlSugar = require('gulp-html-sugar');

return gulp.src('src/example.html').pipe(htmlSugar({
    'icon': function ($, element) {
        const iconName = element.html().trim();
        element.replaceWith($(`<svg class="icon ${iconName}"><use xlink:href="sprite.svg#${iconName}"/></svg>`));
     }
})).pipe(gulp.dest('build/'));

example.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Example page</title>
  </head>
  <body>
    <icon>trash</icon>
  </body>
</html>

Result:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Example page</title>
  </head>
  <body>
    <svg class="icon trash"><use xlink:href="sprite.svg#trash"/></svg>
  </body>
</html>

API

htmlSugar(options)

options.[selector]

Type: function(document, element)

document and element is cheerio objects.

License

MIT © vovanre

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100