All files / html / mod.ts

100.00% Branches 1/1
100.00% Lines 13/13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
x8
 
 
 
x8
 
x8
x8
x8
x8
x10
x11
x11
x11
x10
x8
 
 
x8

















// Imports
import { type Directive, Phase } from "@mizu/internal/engine"
export type * from "@mizu/internal/engine"

/** `*html` directive. */
export const _html: Directive<{
  Default: true
}> = {
  name: "*html",
  phase: Phase.CONTENT,
  async execute(this: typeof _html, renderer, element, { attributes: [attribute], ...options }) {
    if (!renderer.isHtmlElement(element)) {
      return
    }
    element.innerHTML = `${await renderer.evaluate(element, attribute.value, options)}`
  },
}

/** Default exports. */
export default _html