Skip to content

Commit fda411b

Browse files
committedMar 7, 2021
chore: upgrade pug
1 parent 570f735 commit fda411b

File tree

2 files changed

+76
-36
lines changed

2 files changed

+76
-36
lines changed
 

‎examples/pug-loader/dist/webpack-5/bundle.js

+75-35
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@ __webpack_require__.r(__webpack_exports__);
1616

1717
var pug = __webpack_require__(79);
1818

19-
function template(locals) {var pug_html = "", pug_mixins = {}, pug_interp;;var locals_for_with = (locals || {});(function (time) {pug_html = pug_html + "\u003C!-- this partial is used for frontend and backend--\u003E\u003Cdiv class=\"time\"\u003E \u003Cb\u003ECurrent time\u003C\u002Fb\u003E\u003Cp\u003E" + (pug.escape(null == (pug_interp = time.toISOString()) ? "" : pug_interp)) + "\u003C\u002Fp\u003E\u003C\u002Fdiv\u003E\u003Cimg src=\"#{require('.\u002Flogo.png')}\"\u003E";}.call(this,"time" in locals_for_with?locals_for_with.time:typeof time!=="undefined"?time:undefined));;return pug_html;};
19+
function template(locals) {var pug_html = "", pug_mixins = {}, pug_interp;;
20+
var locals_for_with = (locals || {});
21+
22+
(function (time) {
23+
pug_html = pug_html + "\u003C!-- this partial is used for frontend and backend--\u003E\u003Cdiv class=\"time\"\u003E \u003Cb\u003ECurrent time\u003C\u002Fb\u003E\u003Cp\u003E" + (pug.escape(null == (pug_interp = time.toISOString()) ? "" : pug_interp)) + "\u003C\u002Fp\u003E\u003C\u002Fdiv\u003E\u003Cimg src=\"#{require('.\u002Flogo.png')}\"\u003E";
24+
}.call(this, "time" in locals_for_with ?
25+
locals_for_with.time :
26+
typeof time !== 'undefined' ? time : undefined));
27+
;;return pug_html;};
2028
module.exports = template;
2129

2230
/***/ }),
@@ -67,7 +75,7 @@ function pug_merge(a, b) {
6775
}
6876

6977
return a;
70-
};
78+
}
7179

7280
/**
7381
* Process array, object, or string as a string of classes delimited by a space.
@@ -88,7 +96,10 @@ function pug_merge(a, b) {
8896
*/
8997
exports.classes = pug_classes;
9098
function pug_classes_array(val, escaping) {
91-
var classString = '', className, padding = '', escapeEnabled = Array.isArray(escaping);
99+
var classString = '',
100+
className,
101+
padding = '',
102+
escapeEnabled = Array.isArray(escaping);
92103
for (var i = 0; i < val.length; i++) {
93104
className = pug_classes(val[i]);
94105
if (!className) continue;
@@ -99,7 +110,8 @@ function pug_classes_array(val, escaping) {
99110
return classString;
100111
}
101112
function pug_classes_object(val) {
102-
var classString = '', padding = '';
113+
var classString = '',
114+
padding = '';
103115
for (var key in val) {
104116
if (key && val[key] && pug_has_own_property.call(val, key)) {
105117
classString = classString + padding + key;
@@ -140,7 +152,7 @@ function pug_style(val) {
140152
} else {
141153
return val + '';
142154
}
143-
};
155+
}
144156

145157
/**
146158
* Render the given attribute.
@@ -153,25 +165,32 @@ function pug_style(val) {
153165
*/
154166
exports.attr = pug_attr;
155167
function pug_attr(key, val, escaped, terse) {
156-
if (val === false || val == null || !val && (key === 'class' || key === 'style')) {
168+
if (
169+
val === false ||
170+
val == null ||
171+
(!val && (key === 'class' || key === 'style'))
172+
) {
157173
return '';
158174
}
159175
if (val === true) {
160176
return ' ' + (terse ? key : key + '="' + key + '"');
161177
}
162178
var type = typeof val;
163-
if ((type === 'object' || type === 'function') && typeof val.toJSON === 'function') {
179+
if (
180+
(type === 'object' || type === 'function') &&
181+
typeof val.toJSON === 'function'
182+
) {
164183
val = val.toJSON();
165184
}
166185
if (typeof val !== 'string') {
167186
val = JSON.stringify(val);
168187
if (!escaped && val.indexOf('"') !== -1) {
169-
return ' ' + key + '=\'' + val.replace(/'/g, '&#39;') + '\'';
188+
return ' ' + key + "='" + val.replace(/'/g, '&#39;') + "'";
170189
}
171190
}
172191
if (escaped) val = pug_escape(val);
173192
return ' ' + key + '="' + val + '"';
174-
};
193+
}
175194

176195
/**
177196
* Render the given attributes object.
@@ -181,7 +200,7 @@ function pug_attr(key, val, escaped, terse) {
181200
* @return {String}
182201
*/
183202
exports.attrs = pug_attrs;
184-
function pug_attrs(obj, terse){
203+
function pug_attrs(obj, terse) {
185204
var attrs = '';
186205

187206
for (var key in obj) {
@@ -201,7 +220,7 @@ function pug_attrs(obj, terse){
201220
}
202221

203222
return attrs;
204-
};
223+
}
205224

206225
/**
207226
* Escape the given string of `html`.
@@ -213,7 +232,7 @@ function pug_attrs(obj, terse){
213232

214233
var pug_match_html = /["&<>]/;
215234
exports.escape = pug_escape;
216-
function pug_escape(_html){
235+
function pug_escape(_html) {
217236
var html = '' + _html;
218237
var regexResult = pug_match_html.exec(html);
219238
if (!regexResult) return _html;
@@ -222,19 +241,28 @@ function pug_escape(_html){
222241
var i, lastIndex, escape;
223242
for (i = regexResult.index, lastIndex = 0; i < html.length; i++) {
224243
switch (html.charCodeAt(i)) {
225-
case 34: escape = '&quot;'; break;
226-
case 38: escape = '&amp;'; break;
227-
case 60: escape = '&lt;'; break;
228-
case 62: escape = '&gt;'; break;
229-
default: continue;
244+
case 34:
245+
escape = '&quot;';
246+
break;
247+
case 38:
248+
escape = '&amp;';
249+
break;
250+
case 60:
251+
escape = '&lt;';
252+
break;
253+
case 62:
254+
escape = '&gt;';
255+
break;
256+
default:
257+
continue;
230258
}
231259
if (lastIndex !== i) result += html.substring(lastIndex, i);
232260
lastIndex = i + 1;
233261
result += escape;
234262
}
235263
if (lastIndex !== i) return result + html.substring(lastIndex, i);
236264
else return result;
237-
};
265+
}
238266

239267
/**
240268
* Re-throw the given `err` in context to the
@@ -248,37 +276,49 @@ function pug_escape(_html){
248276
*/
249277

250278
exports.rethrow = pug_rethrow;
251-
function pug_rethrow(err, filename, lineno, str){
279+
function pug_rethrow(err, filename, lineno, str) {
252280
if (!(err instanceof Error)) throw err;
253281
if ((typeof window != 'undefined' || !filename) && !str) {
254282
err.message += ' on line ' + lineno;
255283
throw err;
256284
}
285+
var context, lines, start, end;
257286
try {
258-
str = str || __webpack_require__(993).readFileSync(filename, 'utf8')
287+
str = str || __webpack_require__(993).readFileSync(filename, {encoding: 'utf8'});
288+
context = 3;
289+
lines = str.split('\n');
290+
start = Math.max(lineno - context, 0);
291+
end = Math.min(lines.length, lineno + context);
259292
} catch (ex) {
260-
pug_rethrow(err, null, lineno)
293+
err.message +=
294+
' - could not read from ' + filename + ' (' + ex.message + ')';
295+
pug_rethrow(err, null, lineno);
296+
return;
261297
}
262-
var context = 3
263-
, lines = str.split('\n')
264-
, start = Math.max(lineno - context, 0)
265-
, end = Math.min(lines.length, lineno + context);
266298

267299
// Error context
268-
var context = lines.slice(start, end).map(function(line, i){
269-
var curr = i + start + 1;
270-
return (curr == lineno ? ' > ' : ' ')
271-
+ curr
272-
+ '| '
273-
+ line;
274-
}).join('\n');
300+
context = lines
301+
.slice(start, end)
302+
.map(function(line, i) {
303+
var curr = i + start + 1;
304+
return (curr == lineno ? ' > ' : ' ') + curr + '| ' + line;
305+
})
306+
.join('\n');
275307

276308
// Alter exception message
277309
err.path = filename;
278-
err.message = (filename || 'Pug') + ':' + lineno
279-
+ '\n' + context + '\n\n' + err.message;
310+
try {
311+
err.message =
312+
(filename || 'Pug') +
313+
':' +
314+
lineno +
315+
'\n' +
316+
context +
317+
'\n\n' +
318+
err.message;
319+
} catch (e) {}
280320
throw err;
281-
};
321+
}
282322

283323

284324
/***/ }),

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"html-loader": "2.0.0",
3838
"jest": "26.5.3",
3939
"mini-css-extract-plugin": "1.0.0",
40-
"pug": "2.0.3",
40+
"pug": "3.0.2",
4141
"pug-loader": "2.4.0",
4242
"raw-loader": "4.0.2",
4343
"rimraf": "2.6.3",

0 commit comments

Comments
 (0)
Please sign in to comment.