Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/deno_tag/code.ts>denoTag

A cli command that allows you to write `<deno>` tags in your html files.
Latest
function denoTag
import { denoTag } from "https://deno.land/x/deno_tag@v1.1.0/code.ts";

The main function of deno-tag, it does three things:

  1. Looks for <deno> tags on the supplied text and reads their attributes
  2. Runs deno for each found <deno> tag
  3. Creates a new text where each <deno> tag is replaced by the output of its respective run (from the previous point)

Finally it returns this new changed text.

There are two supported attributes for the <deno> tag:

  • <deno bundle="someCode.ts" />
    • Replaces the tag with the output from running the options.bundler someCode.ts (by default the options.bundler is Deno.bundler)
  • <deno run="someCode.ts" />
    • Replaces the tag with the console output from running options.runner on someCode.ts (by default the options.runner is Deno.run)

It assumes that the file path can be found from Deno.cwd. (see cli.ts) The file paths passed on the <deno> are relative to the location of the file that holds the <deno> tag.

Note: Padding is preserved, the output is set on the text at the same indentation level that the respective <deno> tag is written at.

Parameters

text: string
optional
options: DenoTagOptions