@itrocks/template 0.0.19 → 0.0.20
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/cjs/template.js +4 -10
- package/esm/template.js +4 -10
- package/package.json +1 -1
package/cjs/template.js
CHANGED
@@ -155,6 +155,7 @@ class Template {
|
|
155
155
|
template.doExpression = this.doExpression;
|
156
156
|
template.doHeadLinks = true;
|
157
157
|
template.doLiteral = this.doLiteral;
|
158
|
+
template.doneLinks = this.headLinks;
|
158
159
|
template.included = true;
|
159
160
|
template.onAttribute = this.onAttribute;
|
160
161
|
template.onTagClose = this.onTagClose;
|
@@ -165,6 +166,8 @@ class Template {
|
|
165
166
|
const parsed = await template.parseFile(((path[0] === node_path_1.sep) || (path[1] === ':'))
|
166
167
|
? path
|
167
168
|
: (this.filePath + node_path_1.sep + path));
|
169
|
+
this.headLinks.push(...template.headLinks);
|
170
|
+
this.headTitle = template.headTitle;
|
168
171
|
return parsed.substring(parsed.indexOf('<!--BEGIN-->') + 12, parsed.indexOf('<!--END-->'));
|
169
172
|
}
|
170
173
|
isContextClean() {
|
@@ -210,10 +213,6 @@ class Template {
|
|
210
213
|
if (this.headLinks.length) {
|
211
214
|
const position = this.target.lastIndexOf('>', this.target.indexOf('</head>')) + 1;
|
212
215
|
this.target = this.target.slice(0, position) + '\n\t' + this.headLinks.join('\n\t') + this.target.slice(position);
|
213
|
-
this.doneLinks = new sorted_array_1.SortedArray;
|
214
|
-
this.headLinks = new sorted_array_1.SortedArray;
|
215
|
-
this.doneLinks.distinct = true;
|
216
|
-
this.headLinks.distinct = true;
|
217
216
|
}
|
218
217
|
if (this.headTitle && !this.included) {
|
219
218
|
const position = this.target.indexOf('>', this.target.indexOf('<title') + 6) + 1;
|
@@ -504,11 +503,6 @@ class Template {
|
|
504
503
|
this.index += closeTagName.length + 1;
|
505
504
|
if (inHead && (closeTagName[0] === 'h') && (closeTagName === 'head')) {
|
506
505
|
inHead = false;
|
507
|
-
if (!this.doHeadLinks) {
|
508
|
-
this.doneLinks = this.headLinks;
|
509
|
-
this.headLinks = new sorted_array_1.SortedArray();
|
510
|
-
this.headLinks.distinct = true;
|
511
|
-
}
|
512
506
|
}
|
513
507
|
let shouldInLiteral = this.inLiteral;
|
514
508
|
if (!this.unclosingTags.includes(closeTagName)) {
|
@@ -686,7 +680,7 @@ class Template {
|
|
686
680
|
if (targetTagIndex > -1) {
|
687
681
|
this.sourceToTarget();
|
688
682
|
const headLink = this.target.substring(targetTagIndex);
|
689
|
-
if (!this.doneLinks
|
683
|
+
if (!this.doneLinks.includes(headLink)) {
|
690
684
|
this.headLinks.insert(headLink);
|
691
685
|
}
|
692
686
|
}
|
package/esm/template.js
CHANGED
@@ -150,6 +150,7 @@ export default class Template {
|
|
150
150
|
template.doExpression = this.doExpression;
|
151
151
|
template.doHeadLinks = true;
|
152
152
|
template.doLiteral = this.doLiteral;
|
153
|
+
template.doneLinks = this.headLinks;
|
153
154
|
template.included = true;
|
154
155
|
template.onAttribute = this.onAttribute;
|
155
156
|
template.onTagClose = this.onTagClose;
|
@@ -160,6 +161,8 @@ export default class Template {
|
|
160
161
|
const parsed = await template.parseFile(((path[0] === sep) || (path[1] === ':'))
|
161
162
|
? path
|
162
163
|
: (this.filePath + sep + path));
|
164
|
+
this.headLinks.push(...template.headLinks);
|
165
|
+
this.headTitle = template.headTitle;
|
163
166
|
return parsed.substring(parsed.indexOf('<!--BEGIN-->') + 12, parsed.indexOf('<!--END-->'));
|
164
167
|
}
|
165
168
|
isContextClean() {
|
@@ -205,10 +208,6 @@ export default class Template {
|
|
205
208
|
if (this.headLinks.length) {
|
206
209
|
const position = this.target.lastIndexOf('>', this.target.indexOf('</head>')) + 1;
|
207
210
|
this.target = this.target.slice(0, position) + '\n\t' + this.headLinks.join('\n\t') + this.target.slice(position);
|
208
|
-
this.doneLinks = new SortedArray;
|
209
|
-
this.headLinks = new SortedArray;
|
210
|
-
this.doneLinks.distinct = true;
|
211
|
-
this.headLinks.distinct = true;
|
212
211
|
}
|
213
212
|
if (this.headTitle && !this.included) {
|
214
213
|
const position = this.target.indexOf('>', this.target.indexOf('<title') + 6) + 1;
|
@@ -499,11 +498,6 @@ export default class Template {
|
|
499
498
|
this.index += closeTagName.length + 1;
|
500
499
|
if (inHead && (closeTagName[0] === 'h') && (closeTagName === 'head')) {
|
501
500
|
inHead = false;
|
502
|
-
if (!this.doHeadLinks) {
|
503
|
-
this.doneLinks = this.headLinks;
|
504
|
-
this.headLinks = new SortedArray();
|
505
|
-
this.headLinks.distinct = true;
|
506
|
-
}
|
507
501
|
}
|
508
502
|
let shouldInLiteral = this.inLiteral;
|
509
503
|
if (!this.unclosingTags.includes(closeTagName)) {
|
@@ -681,7 +675,7 @@ export default class Template {
|
|
681
675
|
if (targetTagIndex > -1) {
|
682
676
|
this.sourceToTarget();
|
683
677
|
const headLink = this.target.substring(targetTagIndex);
|
684
|
-
if (!this.doneLinks
|
678
|
+
if (!this.doneLinks.includes(headLink)) {
|
685
679
|
this.headLinks.insert(headLink);
|
686
680
|
}
|
687
681
|
}
|
package/package.json
CHANGED