Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kawarimidoll/deno-markup-tag
Render markup tag easily
https://github.com/kawarimidoll/deno-markup-tag
deno deno-module denoland html markup svg
Last synced: 3 months ago
JSON representation
Render markup tag easily
- Host: GitHub
- URL: https://github.com/kawarimidoll/deno-markup-tag
- Owner: kawarimidoll
- License: mit
- Created: 2021-07-24T07:06:07.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-07-06T05:40:46.000Z (7 months ago)
- Last Synced: 2024-10-17T18:46:33.440Z (4 months ago)
- Topics: deno, deno-module, denoland, html, markup, svg
- Language: TypeScript
- Homepage: https://deno.land/x/markup_tag
- Size: 123 KB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
`,# deno-markup-tag
[![ci](https://github.com/kawarimidoll/deno-markup-tag/workflows/ci/badge.svg)](.github/workflows/ci.yml)
[![deno version](https://img.shields.io/badge/deno-%5E1.13.0-green?logo=deno)](https://deno.land)
[![LICENSE](https://img.shields.io/badge/license-MIT-brightgreen)](LICENSE)
[![deno.land](https://img.shields.io/github/v/tag/kawarimidoll/deno-markup-tag?style=flat&logo=deno&label=deno.land&color=steelblue&sort=semver)](https://deno.land/x/markup_tag)
[![nest badge](https://nest.land/badge.svg)](https://nest.land/package/markup-tag)## Usage
[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/markup_tag/mod.ts)
### Import
From [deno.land/x](https://deno.land/x):
```ts
import { tag } from "https://deno.land/x/[email protected]/mod.ts";
```From [x.nest.land](http://nest.land):
```ts
import { tag } from "https://x.nest.land/[email protected]/mod.ts";
```From [pax.deno.dev](http://pax.deno.dev):
```ts
import { tag } from "https://pax.deno.dev/kawarimidoll/[email protected]";
```### tag
Render markup tag.
```ts
`,
// common usage
assertEquals(
tag("div", { id: "foo", class: "bar" }, "Hello world!"),
`
);// void (no-close) tag
assertEquals(tag("meta", { charset: "utf-8" }), ``);// nested tags
assertEquals(
tag("ul", { class: "nav" }, tag("li", "first"), tag("li", "second")),
`
);
// boolean attributes
assertEquals(
tag("button", { type: "button", disabled: true }, "disabled"),
`disabled`,
);
// skip attributes
assertEquals(
tag("input", { type: "text", readonly: false }),
``,
);
```
### Character references
These constants are exported.
```ts
const NBSP = " ";
const LT = "<";
const GT = ">";
const AMP = "&";
const QUOT = """;
```
### sanitize
Sanitize `&`, `<`, `>` and `"` in string.
```ts
// common usage
assertEquals(
sanitize(``),
"<img src="https://www.example.com?width=10&height=10">",
);
// ignore sanitizing specific characters
assertEquals(sanitize("
", { lt: false, gt: false }), "
");
```