npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

html-transformer

1.1.2 • Public • Published

html-transformer

HTML transformer

npm version Build Status codecov dependencies Status devDependencies Status

Example

import Transformer from "html-transformer";
 
let env = {};
/**
  set env
 */
 
const transformer = new Transformer();
transformer.onText(/{{[^}]+}}/, (_, matched) => {
    return env[matched[1]];
})
.onTag("*", "placeholder", /{{[^}]+}}/, (_, matched) => {
    return env[matched[1]];
})
.onBeforeClosingTag("body", () => {
    return "<script src=\"inject_some_js.js\"></script>";
}).pipe(htmlOutput);
htmlInput.pipe(transformer);

Keywords

install

npm i html-transformer

Downloadsweekly downloads

10

version

1.1.2

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability