ghtml 2.1.0 → 2.1.1
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/.eslintrc.json +1 -3
- package/package.json +1 -1
- package/src/html.js +11 -14
package/.eslintrc.json
CHANGED
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.1",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"bin": "./bin/src/index.js",
|
|
9
9
|
"main": "./src/index.js",
|
package/src/html.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const escapeRegExp = /["&'<>`]/;
|
|
2
|
+
|
|
2
3
|
const escapeFunction = (string) => {
|
|
3
4
|
const stringLength = string.length;
|
|
4
5
|
let start = 0;
|
|
5
|
-
let end = 0;
|
|
6
6
|
let escaped = "";
|
|
7
7
|
|
|
8
|
-
for (; end !== stringLength; ++end) {
|
|
8
|
+
for (let end = 0; end !== stringLength; ++end) {
|
|
9
9
|
switch (string.charCodeAt(end)) {
|
|
10
10
|
case 34: // "
|
|
11
11
|
escaped += string.slice(start, end) + """;
|
|
@@ -34,7 +34,7 @@ const escapeFunction = (string) => {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
escaped += string.slice(start,
|
|
37
|
+
escaped += string.slice(start, stringLength);
|
|
38
38
|
|
|
39
39
|
return escaped;
|
|
40
40
|
};
|
|
@@ -46,10 +46,9 @@ const escapeFunction = (string) => {
|
|
|
46
46
|
*/
|
|
47
47
|
const html = ({ raw: literals }, ...expressions) => {
|
|
48
48
|
const expressionsLength = expressions.length;
|
|
49
|
-
let index = 0;
|
|
50
49
|
let accumulator = "";
|
|
51
50
|
|
|
52
|
-
for (; index !== expressionsLength; ++index) {
|
|
51
|
+
for (let index = 0; index !== expressionsLength; ++index) {
|
|
53
52
|
const expression = expressions[index];
|
|
54
53
|
let literal = literals[index];
|
|
55
54
|
let string =
|
|
@@ -70,7 +69,7 @@ const html = ({ raw: literals }, ...expressions) => {
|
|
|
70
69
|
accumulator += literal + string;
|
|
71
70
|
}
|
|
72
71
|
|
|
73
|
-
accumulator += literals[
|
|
72
|
+
accumulator += literals[expressionsLength];
|
|
74
73
|
|
|
75
74
|
return accumulator;
|
|
76
75
|
};
|
|
@@ -82,9 +81,8 @@ const html = ({ raw: literals }, ...expressions) => {
|
|
|
82
81
|
*/
|
|
83
82
|
const htmlGenerator = function* ({ raw: literals }, ...expressions) {
|
|
84
83
|
const expressionsLength = expressions.length;
|
|
85
|
-
let index = 0;
|
|
86
84
|
|
|
87
|
-
for (; index !== expressionsLength; ++index) {
|
|
85
|
+
for (let index = 0; index !== expressionsLength; ++index) {
|
|
88
86
|
let expression = expressions[index];
|
|
89
87
|
let literal = literals[index];
|
|
90
88
|
let string;
|
|
@@ -167,8 +165,8 @@ const htmlGenerator = function* ({ raw: literals }, ...expressions) {
|
|
|
167
165
|
}
|
|
168
166
|
}
|
|
169
167
|
|
|
170
|
-
if (literals[
|
|
171
|
-
yield literals[
|
|
168
|
+
if (literals[expressionsLength]) {
|
|
169
|
+
yield literals[expressionsLength];
|
|
172
170
|
}
|
|
173
171
|
};
|
|
174
172
|
|
|
@@ -179,9 +177,8 @@ const htmlGenerator = function* ({ raw: literals }, ...expressions) {
|
|
|
179
177
|
*/
|
|
180
178
|
const htmlAsyncGenerator = async function* ({ raw: literals }, ...expressions) {
|
|
181
179
|
const expressionsLength = expressions.length;
|
|
182
|
-
let index = 0;
|
|
183
180
|
|
|
184
|
-
for (; index !== expressionsLength; ++index) {
|
|
181
|
+
for (let index = 0; index !== expressionsLength; ++index) {
|
|
185
182
|
let expression = await expressions[index];
|
|
186
183
|
let literal = literals[index];
|
|
187
184
|
let string;
|
|
@@ -267,8 +264,8 @@ const htmlAsyncGenerator = async function* ({ raw: literals }, ...expressions) {
|
|
|
267
264
|
}
|
|
268
265
|
}
|
|
269
266
|
|
|
270
|
-
if (literals[
|
|
271
|
-
yield literals[
|
|
267
|
+
if (literals[expressionsLength]) {
|
|
268
|
+
yield literals[expressionsLength];
|
|
272
269
|
}
|
|
273
270
|
};
|
|
274
271
|
|