0.0.4 • Published 5 years ago

@infektweb/injectjs v0.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

injectjs

Helper methods to:

  • Inject a javascript tag with some javascript into a html file
  • Inject environment variables into html as env.ENV_VAR = "X"

Inject js

import { injectJs } from '@infektweb/injectjs'

injectJs('<html><head></head><body></body></html>', 'alert("FOO")')
// <html><head><script type="javascript">alert("FOO")</script></head><body></body></html>

Inject env

import { injectEnv } from '@infektweb/injectjs'

injectEnv('<html><head></head><body></body></html>', {
  Foo: 'foo',
  TERM: 'foo',
})
// <html><head><script type="javascript">
// window.env = {};
// window.env.FOO = 'foo';
// window.env.TERM = 'xterm-256color';
// </script></head><body></body></html>
0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago