ghtml 3.0.2 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/html.d.ts +3 -24
- package/src/html.js +14 -11
- package/src/includeFile.d.ts +0 -4
- package/src/includeFile.js +2 -4
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Replace your template engine with fast JavaScript by leveraging the power of tagged templates.",
|
|
4
4
|
"author": "Gürgün Dayıoğlu",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "3.0.
|
|
6
|
+
"version": "3.0.3",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"bin": "./bin/src/index.js",
|
|
9
9
|
"main": "./src/index.js",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@fastify/pre-commit": "^2.1.0",
|
|
29
29
|
"c8": "^10.1.2",
|
|
30
|
-
"grules": "^0.23.
|
|
31
|
-
"tinybench": "^2.
|
|
30
|
+
"grules": "^0.23.3",
|
|
31
|
+
"tinybench": "^2.9.0",
|
|
32
32
|
"typescript": ">=5.5.4"
|
|
33
33
|
},
|
|
34
34
|
"repository": {
|
package/src/html.d.ts
CHANGED
|
@@ -1,24 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* @returns {string} The HTML string.
|
|
5
|
-
*/
|
|
6
|
-
export function html({ raw: literals }: {
|
|
7
|
-
raw: Readonly<string[]>;
|
|
8
|
-
}, ...expressions: any[]): string;
|
|
9
|
-
/**
|
|
10
|
-
* @param {{ raw: Readonly<string[]> }} literals Tagged template literals.
|
|
11
|
-
* @param {...any} expressions Expressions to interpolate.
|
|
12
|
-
* @yields {string} The HTML strings.
|
|
13
|
-
*/
|
|
14
|
-
export function htmlGenerator({ raw: literals }: {
|
|
15
|
-
raw: Readonly<string[]>;
|
|
16
|
-
}, ...expressions: any[]): {};
|
|
17
|
-
/**
|
|
18
|
-
* @param {{ raw: Readonly<string[]> }} literals Tagged template literals.
|
|
19
|
-
* @param {...any} expressions Expressions to interpolate.
|
|
20
|
-
* @yields {string} The HTML strings.
|
|
21
|
-
*/
|
|
22
|
-
export function htmlAsyncGenerator({ raw: literals }: {
|
|
23
|
-
raw: Readonly<string[]>;
|
|
24
|
-
}, ...expressions: any[]): {};
|
|
1
|
+
export function html({ raw: literals }: TemplateStringsArray, ...expressions: any[]): string;
|
|
2
|
+
export function htmlGenerator({ raw: literals }: TemplateStringsArray, ...expressions: any[]): Generator<string, void, void>;
|
|
3
|
+
export function htmlAsyncGenerator({ raw: literals }: TemplateStringsArray, ...expressions: any[]): AsyncGenerator<string, void, void>;
|
package/src/html.js
CHANGED
|
@@ -39,11 +39,11 @@ const escapeFunction = (string) => {
|
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
* @param {
|
|
42
|
+
* @param {TemplateStringsArray} literals Tagged template literals.
|
|
43
43
|
* @param {...any} expressions Expressions to interpolate.
|
|
44
|
-
* @returns {string} The HTML string.
|
|
44
|
+
* @returns {string} The processed HTML string.
|
|
45
45
|
*/
|
|
46
|
-
const html = ({ raw: literals }, ...expressions) => {
|
|
46
|
+
export const html = ({ raw: literals }, ...expressions) => {
|
|
47
47
|
let accumulator = "";
|
|
48
48
|
|
|
49
49
|
for (let i = 0; i !== expressions.length; ++i) {
|
|
@@ -72,11 +72,12 @@ const html = ({ raw: literals }, ...expressions) => {
|
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
|
-
* @param {
|
|
75
|
+
* @param {TemplateStringsArray} literals Tagged template literals.
|
|
76
76
|
* @param {...any} expressions Expressions to interpolate.
|
|
77
|
-
* @yields
|
|
77
|
+
* @yields Processed HTML strings.
|
|
78
|
+
* @returns {Generator<string, void, void>} The HTML generator.
|
|
78
79
|
*/
|
|
79
|
-
const htmlGenerator = function* ({ raw: literals }, ...expressions) {
|
|
80
|
+
export const htmlGenerator = function* ({ raw: literals }, ...expressions) {
|
|
80
81
|
for (let i = 0; i !== expressions.length; ++i) {
|
|
81
82
|
let expression = expressions[i];
|
|
82
83
|
let literal = literals[i];
|
|
@@ -166,11 +167,15 @@ const htmlGenerator = function* ({ raw: literals }, ...expressions) {
|
|
|
166
167
|
};
|
|
167
168
|
|
|
168
169
|
/**
|
|
169
|
-
* @param {
|
|
170
|
+
* @param {TemplateStringsArray} literals Tagged template literals.
|
|
170
171
|
* @param {...any} expressions Expressions to interpolate.
|
|
171
|
-
* @yields
|
|
172
|
+
* @yields Processed HTML strings.
|
|
173
|
+
* @returns {AsyncGenerator<string, void, void>} The HTML generator.
|
|
172
174
|
*/
|
|
173
|
-
const htmlAsyncGenerator = async function* (
|
|
175
|
+
export const htmlAsyncGenerator = async function* (
|
|
176
|
+
{ raw: literals },
|
|
177
|
+
...expressions
|
|
178
|
+
) {
|
|
174
179
|
for (let i = 0; i !== expressions.length; ++i) {
|
|
175
180
|
let expression = await expressions[i];
|
|
176
181
|
let literal = literals[i];
|
|
@@ -261,5 +266,3 @@ const htmlAsyncGenerator = async function* ({ raw: literals }, ...expressions) {
|
|
|
261
266
|
yield literals[expressions.length];
|
|
262
267
|
}
|
|
263
268
|
};
|
|
264
|
-
|
|
265
|
-
export { html, htmlGenerator, htmlAsyncGenerator };
|
package/src/includeFile.d.ts
CHANGED
package/src/includeFile.js
CHANGED
|
@@ -4,9 +4,9 @@ const cache = new Map();
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @param {string} path The path to the file to render.
|
|
7
|
-
* @returns {string} The
|
|
7
|
+
* @returns {string} The content of the file.
|
|
8
8
|
*/
|
|
9
|
-
const includeFile = (path) => {
|
|
9
|
+
export const includeFile = (path) => {
|
|
10
10
|
let file = cache.get(path);
|
|
11
11
|
|
|
12
12
|
if (file === undefined) {
|
|
@@ -16,5 +16,3 @@ const includeFile = (path) => {
|
|
|
16
16
|
|
|
17
17
|
return file;
|
|
18
18
|
};
|
|
19
|
-
|
|
20
|
-
export { includeFile };
|