ghtml 2.1.3 → 2.1.5
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
console.warn("Hello World!");
|
package/bin/example/package.json
CHANGED
|
@@ -22,7 +22,7 @@ export default async (fastify) => {
|
|
|
22
22
|
fastify.get("/", async (request, reply) => {
|
|
23
23
|
return reply.html`
|
|
24
24
|
<h1 class="caption">Hello, world!</h1>
|
|
25
|
-
<
|
|
25
|
+
<script src="/p/assets/script.js"></script>
|
|
26
26
|
`;
|
|
27
27
|
});
|
|
28
28
|
};
|
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": "2.1.
|
|
6
|
+
"version": "2.1.5",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"bin": "./bin/src/index.js",
|
|
9
9
|
"main": "./src/index.js",
|
package/src/html.js
CHANGED
|
@@ -3,9 +3,8 @@ const escapeRegExp = /["&'<>`]/;
|
|
|
3
3
|
const escapeFunction = (string) => {
|
|
4
4
|
let escaped = "";
|
|
5
5
|
let start = 0;
|
|
6
|
-
let end = 0;
|
|
7
6
|
|
|
8
|
-
for (; end !== string.length; ++end) {
|
|
7
|
+
for (let end = 0; end !== string.length; ++end) {
|
|
9
8
|
switch (string.charCodeAt(end)) {
|
|
10
9
|
case 34: // "
|
|
11
10
|
escaped += string.slice(start, end) + """;
|
|
@@ -34,7 +33,7 @@ const escapeFunction = (string) => {
|
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
escaped += string.slice(start,
|
|
36
|
+
escaped += string.slice(start, string.length);
|
|
38
37
|
|
|
39
38
|
return escaped;
|
|
40
39
|
};
|
|
@@ -46,11 +45,10 @@ const escapeFunction = (string) => {
|
|
|
46
45
|
*/
|
|
47
46
|
const html = ({ raw: literals }, ...expressions) => {
|
|
48
47
|
let accumulator = "";
|
|
49
|
-
let index = 0;
|
|
50
48
|
|
|
51
|
-
for (;
|
|
52
|
-
const expression = expressions[
|
|
53
|
-
let literal = literals[
|
|
49
|
+
for (let i = 0; i !== expressions.length; ++i) {
|
|
50
|
+
const expression = expressions[i];
|
|
51
|
+
let literal = literals[i];
|
|
54
52
|
let string =
|
|
55
53
|
typeof expression === "string"
|
|
56
54
|
? expression
|
|
@@ -69,7 +67,7 @@ const html = ({ raw: literals }, ...expressions) => {
|
|
|
69
67
|
accumulator += literal + string;
|
|
70
68
|
}
|
|
71
69
|
|
|
72
|
-
accumulator += literals[
|
|
70
|
+
accumulator += literals[expressions.length];
|
|
73
71
|
|
|
74
72
|
return accumulator;
|
|
75
73
|
};
|
|
@@ -80,11 +78,9 @@ const html = ({ raw: literals }, ...expressions) => {
|
|
|
80
78
|
* @yields {string} The HTML strings.
|
|
81
79
|
*/
|
|
82
80
|
const htmlGenerator = function* ({ raw: literals }, ...expressions) {
|
|
83
|
-
let
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
let expression = expressions[index];
|
|
87
|
-
let literal = literals[index];
|
|
81
|
+
for (let i = 0; i !== expressions.length; ++i) {
|
|
82
|
+
let expression = expressions[i];
|
|
83
|
+
let literal = literals[i];
|
|
88
84
|
let string;
|
|
89
85
|
|
|
90
86
|
if (typeof expression === "string") {
|
|
@@ -165,8 +161,8 @@ const htmlGenerator = function* ({ raw: literals }, ...expressions) {
|
|
|
165
161
|
}
|
|
166
162
|
}
|
|
167
163
|
|
|
168
|
-
if (literals[
|
|
169
|
-
yield literals[
|
|
164
|
+
if (literals[expressions.length]) {
|
|
165
|
+
yield literals[expressions.length];
|
|
170
166
|
}
|
|
171
167
|
};
|
|
172
168
|
|
|
@@ -176,11 +172,9 @@ const htmlGenerator = function* ({ raw: literals }, ...expressions) {
|
|
|
176
172
|
* @yields {string} The HTML strings.
|
|
177
173
|
*/
|
|
178
174
|
const htmlAsyncGenerator = async function* ({ raw: literals }, ...expressions) {
|
|
179
|
-
let
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
let expression = await expressions[index];
|
|
183
|
-
let literal = literals[index];
|
|
175
|
+
for (let i = 0; i !== expressions.length; ++i) {
|
|
176
|
+
let expression = await expressions[i];
|
|
177
|
+
let literal = literals[i];
|
|
184
178
|
let string;
|
|
185
179
|
|
|
186
180
|
if (typeof expression === "string") {
|
|
@@ -264,8 +258,8 @@ const htmlAsyncGenerator = async function* ({ raw: literals }, ...expressions) {
|
|
|
264
258
|
}
|
|
265
259
|
}
|
|
266
260
|
|
|
267
|
-
if (literals[
|
|
268
|
-
yield literals[
|
|
261
|
+
if (literals[expressions.length]) {
|
|
262
|
+
yield literals[expressions.length];
|
|
269
263
|
}
|
|
270
264
|
};
|
|
271
265
|
|
|
Binary file
|