@infektweb/injectjs
v0.0.4
Published
Downloads
2
Readme
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>