7.1.0 • Published 4 months ago

@gurgunday/html v7.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

Replace your template engine with fast JavaScript by leveraging the power of tagged templates.

Inspired by html-template-tag.

Installation

npm i @gurgunday/html

API Reference

The main export of the package is the html function that can be used to tag template literals and escape their expressions. To bypass escaping an expression, prefix it with !.

Node.js users also have access to the includeFile function that reads and outputs the content of a file while caching it in memory for future use.

Usage

import { html } from "@gurgunday/html";

const username = '<img src="https://example.com/hacker.png">';
const greeting = html`<h1>Hello, ${username}!</h1>`;

console.log(greeting);
// Output: <h1>Hello, &lt;img src=&quot;https://example.com/hacker.png&quot;&gt;</h1>

const img = '<img src="https://example.com/safe.png">';
const container = html`<div>!${img}</div>`;

console.log(container);
// Output: <div><img src="https://example.com/safe.png"></div>

The includeFile function returns the content of a file. Again, remember that it also caches the result, so any subsequent modifications to the same file won't be reflected until the app is restarted:

import { includeFile } from "@gurgunday/html/includeFile.js";

const logo = includeFile("static/logo.svg");

console.log(logo);
// Output: content of "static/logo.svg"
7.1.0

4 months ago

5.6.0

8 months ago

5.5.0

8 months ago

5.4.0

8 months ago

5.2.0

8 months ago

5.0.0

8 months ago

6.1.0

6 months ago

6.0.1

6 months ago

6.0.0

7 months ago

6.2.0

6 months ago

6.5.0

6 months ago

6.2.2

6 months ago

5.10.5

7 months ago

2.1.1

10 months ago

5.10.0

7 months ago

2.1.5

10 months ago

7.0.0

5 months ago

7.0.2

5 months ago

2.0.1

10 months ago

7.0.1

5 months ago

2.0.0

10 months ago

6.5.1

6 months ago

4.2.2

8 months ago

6.5.3

6 months ago

4.1.0

9 months ago

6.5.5

6 months ago

4.0.0

10 months ago

4.2.1

8 months ago

4.2.0

9 months ago

4.1.1

9 months ago

5.8.0

7 months ago

5.7.0

7 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago