github-actions
released this
18 Oct 15:04
·
2 commits
to main
since this release
Minor Changes
-
5088e8d: HTML
Injector
Easily manipulate HTML on the server with the
Injector
helper. -
Stabilizes the HTML
Injector
helper -
Adds
Injector
testsimport { Injector } from "domco/injector"; const injector = new Injector( `<!doctype html><html><body><!-- comment --></body></html>`, ); injector // Set or change the title .title("My Title") // pass a TagDescriptor .head([{ name: "script", attrs: { type: "module", src: "./script.js" } }]) // pass a string of text .body("Prepended to the body! ", "prepend") // replace comments .comment("comment", "My comment") // stringify HTML .toString();
Produces the following HTML.
<!doctype html> <html> <head> <title>My Title</title> <script type="module" src="./script.js"></script> </head> <body> Prepended to the body! My comment </body> </html>