Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/fresh/plugins/twindv1_deps.ts>extract

The next-gen web framework.
Extremely Popular
Go to Latest
function extract
import { extract } from "https://deno.land/x/fresh@1.6.1/plugins/twindv1_deps.ts";

Used for static HTML processing (usually to provide SSR support for your javascript-powered web apps)

Note: Consider using inline instead.

  1. parse the markup and process element classes with the provided Twind instance
  2. update the class attributes if necessary
  3. return the HTML string with the final element classes
import { extract } from '@twind/core'

function render() {
  const { html, css } = extract(renderApp())

  // inject as last element into the head
  return html.replace('</head>', `<style data-twind>${css}</style></head>`)
}

You can provide your own Twind instance:

import { extract } from '@twind/core'
import { tw } from './custom/twind/instance'

function render() {
  const { html, css } = extract(renderApp(), tw)

  // inject as last element into the head
  return html.replace('</head>', `<style data-twind>${css}</style></head>`)
}

Parameters

html: string

HTML to process

optional
tw: Twind<any, any>

a Twind instance (default: twind managed tw)

Returns

the possibly modified html and css