Skip to content

Commit

Permalink
chore: upgrade pug
Browse files Browse the repository at this point in the history
  • Loading branch information
jantimon committed Mar 7, 2021
1 parent 570f735 commit fda411b
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 36 deletions.
110 changes: 75 additions & 35 deletions examples/pug-loader/dist/webpack-5/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@ __webpack_require__.r(__webpack_exports__);

var pug = __webpack_require__(79);

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;};
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;};
module.exports = template;

/***/ }),
Expand Down Expand Up @@ -67,7 +75,7 @@ function pug_merge(a, b) {
}

return a;
};
}

/**
* Process array, object, or string as a string of classes delimited by a space.
Expand All @@ -88,7 +96,10 @@ function pug_merge(a, b) {
*/
exports.classes = pug_classes;
function pug_classes_array(val, escaping) {
var classString = '', className, padding = '', escapeEnabled = Array.isArray(escaping);
var classString = '',
className,
padding = '',
escapeEnabled = Array.isArray(escaping);
for (var i = 0; i < val.length; i++) {
className = pug_classes(val[i]);
if (!className) continue;
Expand All @@ -99,7 +110,8 @@ function pug_classes_array(val, escaping) {
return classString;
}
function pug_classes_object(val) {
var classString = '', padding = '';
var classString = '',
padding = '';
for (var key in val) {
if (key && val[key] && pug_has_own_property.call(val, key)) {
classString = classString + padding + key;
Expand Down Expand Up @@ -140,7 +152,7 @@ function pug_style(val) {
} else {
return val + '';
}
};
}

/**
* Render the given attribute.
Expand All @@ -153,25 +165,32 @@ function pug_style(val) {
*/
exports.attr = pug_attr;
function pug_attr(key, val, escaped, terse) {
if (val === false || val == null || !val && (key === 'class' || key === 'style')) {
if (
val === false ||
val == null ||
(!val && (key === 'class' || key === 'style'))
) {
return '';
}
if (val === true) {
return ' ' + (terse ? key : key + '="' + key + '"');
}
var type = typeof val;
if ((type === 'object' || type === 'function') && typeof val.toJSON === 'function') {
if (
(type === 'object' || type === 'function') &&
typeof val.toJSON === 'function'
) {
val = val.toJSON();
}
if (typeof val !== 'string') {
val = JSON.stringify(val);
if (!escaped && val.indexOf('"') !== -1) {
return ' ' + key + '=\'' + val.replace(/'/g, '&#39;') + '\'';
return ' ' + key + "='" + val.replace(/'/g, '&#39;') + "'";
}
}
if (escaped) val = pug_escape(val);
return ' ' + key + '="' + val + '"';
};
}

/**
* Render the given attributes object.
Expand All @@ -181,7 +200,7 @@ function pug_attr(key, val, escaped, terse) {
* @return {String}
*/
exports.attrs = pug_attrs;
function pug_attrs(obj, terse){
function pug_attrs(obj, terse) {
var attrs = '';

for (var key in obj) {
Expand All @@ -201,7 +220,7 @@ function pug_attrs(obj, terse){
}

return attrs;
};
}

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

var pug_match_html = /["&<>]/;
exports.escape = pug_escape;
function pug_escape(_html){
function pug_escape(_html) {
var html = '' + _html;
var regexResult = pug_match_html.exec(html);
if (!regexResult) return _html;
Expand All @@ -222,19 +241,28 @@ function pug_escape(_html){
var i, lastIndex, escape;
for (i = regexResult.index, lastIndex = 0; i < html.length; i++) {
switch (html.charCodeAt(i)) {
case 34: escape = '&quot;'; break;
case 38: escape = '&amp;'; break;
case 60: escape = '&lt;'; break;
case 62: escape = '&gt;'; break;
default: continue;
case 34:
escape = '&quot;';
break;
case 38:
escape = '&amp;';
break;
case 60:
escape = '&lt;';
break;
case 62:
escape = '&gt;';
break;
default:
continue;
}
if (lastIndex !== i) result += html.substring(lastIndex, i);
lastIndex = i + 1;
result += escape;
}
if (lastIndex !== i) return result + html.substring(lastIndex, i);
else return result;
};
}

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

exports.rethrow = pug_rethrow;
function pug_rethrow(err, filename, lineno, str){
function pug_rethrow(err, filename, lineno, str) {
if (!(err instanceof Error)) throw err;
if ((typeof window != 'undefined' || !filename) && !str) {
err.message += ' on line ' + lineno;
throw err;
}
var context, lines, start, end;
try {
str = str || __webpack_require__(993).readFileSync(filename, 'utf8')
str = str || __webpack_require__(993).readFileSync(filename, {encoding: 'utf8'});
context = 3;
lines = str.split('\n');
start = Math.max(lineno - context, 0);
end = Math.min(lines.length, lineno + context);
} catch (ex) {
pug_rethrow(err, null, lineno)
err.message +=
' - could not read from ' + filename + ' (' + ex.message + ')';
pug_rethrow(err, null, lineno);
return;
}
var context = 3
, lines = str.split('\n')
, start = Math.max(lineno - context, 0)
, end = Math.min(lines.length, lineno + context);

// Error context
var context = lines.slice(start, end).map(function(line, i){
var curr = i + start + 1;
return (curr == lineno ? ' > ' : ' ')
+ curr
+ '| '
+ line;
}).join('\n');
context = lines
.slice(start, end)
.map(function(line, i) {
var curr = i + start + 1;
return (curr == lineno ? ' > ' : ' ') + curr + '| ' + line;
})
.join('\n');

// Alter exception message
err.path = filename;
err.message = (filename || 'Pug') + ':' + lineno
+ '\n' + context + '\n\n' + err.message;
try {
err.message =
(filename || 'Pug') +
':' +
lineno +
'\n' +
context +
'\n\n' +
err.message;
} catch (e) {}
throw err;
};
}


/***/ }),
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"html-loader": "2.0.0",
"jest": "26.5.3",
"mini-css-extract-plugin": "1.0.0",
"pug": "2.0.3",
"pug": "3.0.2",
"pug-loader": "2.4.0",
"raw-loader": "4.0.2",
"rimraf": "2.6.3",
Expand Down

0 comments on commit fda411b

Please sign in to comment.