posthtml-script-to-file

0.1.1 • Public • Published

[![NPM][npm]][npm-url] [![Deps][deps]][deps-url] [![Tests][travis]][travis-url] [![Coverage][cover]][cover-url]

posthtml-script-to-file

Install

npm i -D posthtml-script-to-file

Usage

Example

const posthtml = require('posthtml')
const scriptToFile = require('posthtml-script-to-file')
 
const html = readFileSync('path/to/html', 'utf8')
 
posthtml([ scriptToFile({ path: './dist/index.js' }) ])
    .process(html)
    .then((result) => console.log(result.html))

index.html

<html>
<head>
    <title>Wow</title>
    
</head>
<body style="background: #fff;">
  <h3> vnjson  </h3>
  <h4>javascript visual novel engine</h4>
  <script type="text/javascript">
    vnjs.on('preload', function(){
        return ['background.png'];
    });
  </script> 
  <script type="text/javascript">
    vnjs.on('load', function(screen){
        let { parse, next } = this;
          
          parse({
              'scene': 'background',
              'screen': screen
            });
          next();
    });
  </script> 
</body>
</html>

index.js

 
vnjs.on('preload', function(){
        return ['background.png'];
});
 
vnjs.on('load', function(screen){
        let { parse, next } = this;
          
          parse({
              'scene': 'background',
              'screen': screen
            });
          next();
});
 

LICENSE

MIT License (MIT)

Package Sidebar

Install

npm i posthtml-script-to-file

Weekly Downloads

0

Version

0.1.1

License

MIT

Last publish

Collaborators

  • kserks