Skip to content

BIFIT/inline-source

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

inline-source

Inline and compress tags that contain the inline attribute. Supports <script>, <link>, and <img> (including *.svg sources) tags by default, and is easily extensible to handle others.

  1. Write Polymer elements with ES2015
  2. Run gulp
  3. ???????
  4. PROFIT

Usage

inline(htmlpath, [options], callback(err, html)): asynchronously parse htmlpath content for tags containing an inline attribute, and replace with (optionally compressed) file contents.

htmlpath can be either a filepath or a string of html content.

Available options include:

  • attribute: attribute used to parse sources (default inline)
  • compress: enable/disable compression of inlined content (default true)
  • es5: enable/disable traceur converter (default false)
  • handlers: specify custom handlers (default []) [see custom handlers]
  • ignore: disable inlining based on tag, type, and/or format (default [])
  • pretty: maintain leading whitespace when options.compress is false (default false)
  • rootpath: directory path used for resolving inlineable paths (default process.cwd())
  • swallowErrors: enable/disable suppression of errors (default false)
  • svgAsImage: convert <img inline src="*.svg" /> to <img> and not <svg> (default false)
$ npm install https://github.com/BIFIT/inline-source.git
<!-- located at project/src/html/index.html -->
<!DOCTYPE html>
<html>
<head>
<!-- set here webcomponents.js -->  
</head>
<body>
  <polymer-component></polymer-component>
  <script inline src="./polymer-component.js"></script>
</body>
</html>
// polymer-component.js
Polymer({
  is: 'polymer-component'
});

Output:

<html>
  <head>
    <polymer-component></polymer-component>
    <script>Polymer({is:'polymer-component'});</script>
  </head>
  <body>
  </body>
</html>

Install

npm install https://github.com/BIFIT/inline-source.git

Gulp tasks

var gulp = require('gulp');
var inlinesource = require('gulp-inline-source');

gulp.task('inlinepolymer', function () {
  return gulp.src([
    'app/elements/polymer-component/polymer-component.html'
  ], {base: './'})
    .pipe(inlinesource({compress: true, es5: true}))
    .pipe(gulp.dest('.'))

});

About

Tool for inlining flagged js, css, and img sources in html

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 99.1%
  • HTML 0.9%