Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bendrucker/inline-htmlify
Stream JS code in and get an HTML document out
https://github.com/bendrucker/inline-htmlify
Last synced: about 1 month ago
JSON representation
Stream JS code in and get an HTML document out
- Host: GitHub
- URL: https://github.com/bendrucker/inline-htmlify
- Owner: bendrucker
- License: mit
- Created: 2015-10-13T05:10:07.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2019-08-19T22:01:37.000Z (about 5 years ago)
- Last Synced: 2024-04-25T06:20:40.477Z (7 months ago)
- Language: JavaScript
- Homepage:
- Size: 14.6 KB
- Stars: 9
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# inline-htmlify [![Build Status](https://travis-ci.org/bendrucker/inline-htmlify.svg?branch=master)](https://travis-ci.org/bendrucker/inline-htmlify) [![Greenkeeper badge](https://badges.greenkeeper.io/bendrucker/inline-htmlify.svg)](https://greenkeeper.io/)
> Stream JS code in and get an HTML document out
## Install
```
$ npm install --save inline-htmlify
```## Usage
```js
var htmlify = require('inline-htmlify')browserify('app.js')
.pipe(htmlify())
.pipe(fs.createWriteStream('index.html'))
``````sh
browserify app.js | htmlify > index.html
```Or using a custom document (`doc.html`):
```js
browserify('app.js')
.pipe(htmlify(fs.createReadStream('doc.html')))
.pipe(fs.createWriteStream('index.html'))
``````sh
cat script.js | htmlify doc.html > index.html
```The html file `doc.html` should have a `` tag with the attribute `inline-htmlify`:
```html
<script inline-htmlify>
```## API
#### `htmlify(document)` -> `stream`
Returns a stream that takes in JavaScript and wraps it in an HTML document.
##### document
A streaming HTML document. The script will be inserted inside a `` tag. The attribute is used to locate the insertion point and is removed from the final output.
Type: `stream`
Default: stream of [`document.html`](document.html)## License
MIT © [Ben Drucker](http://bendrucker.me)