Inject template into innerHTML
npm install inject-template``sh`
$ npm install --save inject-template
`js
var injectTemplate = require('inject-template');
let result = injectTemplate.inject({path: 'rainbow.js'}) // injects content from rainbow.html
// dosomething with result ...
`
js
class Rainbow extends HTMLElement {
constructor() {
super();
this.innerHTML = 'BIG RAINBOW';
}
...
}
`#### rainbow.js 1
`js
class Rainbow extends HTMLElement {
constructor() {
super();
// @template rainbow
}
...
}
`#### rainbow.html 2
`html
BIG RAINBOW
`$3
`js
var injectTemplate = require('inject-template');let result = injectTemplate.inject({path: 'rainbow.js', name: 'rainbow-template'}) // injects content from rainbow-template.html
`$3
`js
var injectTemplate = require('inject-template');let result = injectTemplate.inject({path: 'rainbow.js', templatePath: 'templates'}) // injects content from templates/rainbow.html
`API
$3
$3
#### options#### path
Type:
string
Default: nullPath to file containing the template tag
#### templatePath
Type:
string
Default: nullPath to the template (use when your template is in another directory).
When undefined inject-template assumes the template in in the same directory of the element
#### content
Type:
string
Default: null`The content of the element (used in gulp-inject-html-template)
When streaming files, you can pass trough the content so inject-template doesn't need to read the element.
MIT © [Glenn Vandeuren]()
[npm-image]: https://badge.fury.io/js/inject-template.svg
[npm-url]: https://npmjs.org/package/inject-template
[travis-image]: https://travis-ci.org/VandeurenGlenn/inject-template.svg?branch=master
[travis-url]: https://travis-ci.org/VandeurenGlenn/inject-template
[daviddm-image]: https://david-dm.org/VandeurenGlenn/inject-template.svg?theme=shields.io
[daviddm-url]: https://david-dm.org/VandeurenGlenn/inject-template
[coveralls-image]: https://coveralls.io/repos/VandeurenGlenn/inject-template/badge.svg
[coveralls-url]: https://coveralls.io/r/VandeurenGlenn/inject-template