function injectScript
injectScript(
html: string,
content: string
): string

Injects the qunitx runner script block into a dynamic HTML template.

injectScript('<body>{{qunitxScript}}</body>', '<script>run()</script>');
// '<body><script>run()</script></body>' — replaces the explicit marker
injectScript('<h1>{{app}}</h1><body></body>', '<script>run()</script>');
// '<h1>{{app}}</h1><body><script>run()</script></body>' — dynamic template, before </body>
injectScript('<body>static</body>', '<script>run()</script>');
// '<body>static</body>' — a non-template passes through untouched

Parameters

html: string
content: string

Return Type

string

Usage

import { injectScript } from "lib/utils/html.ts";