Skip to content
Compare
Choose a tag to compare
@github-actions github-actions released this 18 Oct 15:04
· 2 commits to main since this release
f0cc3cf

Minor Changes

  • 5088e8d: HTML Injector

    Easily manipulate HTML on the server with the Injector helper.

  • Stabilizes the HTML Injector helper

  • Adds Injector tests

    import { 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>