fix: add scoped error logging for lexer/parser errors
- Add std.log.scoped(.pugz) to template.zig and view_engine.zig - Log detailed error info (code, line, column, message) when parsing fails - Log template path context in ViewEngine on parse errors - Remove debug print from lexer, use proper scoped logging instead - Move benchmarks, docs, examples, playground, tests out of src/ to project root - Update build.zig and documentation paths accordingly - Bump version to 0.3.1
This commit is contained in:
110
tests/sample_data/pug/test/__snapshots__/pug.test.js.snap
Normal file
110
tests/sample_data/pug/test/__snapshots__/pug.test.js.snap
Normal file
@@ -0,0 +1,110 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`pug .compileClient() should support module syntax in pug.compileClient(str, options) when inlineRuntimeFunctions it false 1`] = `
|
||||
"var pug = require(\\"pug-runtime\\");
|
||||
function template(locals) {
|
||||
var pug_html = \\"\\",
|
||||
pug_mixins = {},
|
||||
pug_interp;
|
||||
var pug_debug_filename, pug_debug_line;
|
||||
try {
|
||||
var self = locals || {};
|
||||
pug_debug_line = 1;
|
||||
pug_html = pug_html + '\\\\u003Cdiv class=\\"bar\\"\\\\u003E';
|
||||
pug_debug_line = 1;
|
||||
pug_html =
|
||||
pug_html +
|
||||
pug.escape(null == (pug_interp = self.foo) ? \\"\\" : pug_interp) +
|
||||
\\"\\\\u003C\\\\u002Fdiv\\\\u003E\\";
|
||||
} catch (err) {
|
||||
pug.rethrow(err, pug_debug_filename, pug_debug_line);
|
||||
}
|
||||
return pug_html;
|
||||
}
|
||||
module.exports = template;
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`pug .compileClient() should support module syntax in pug.compileClient(str, options) when inlineRuntimeFunctions it true 1`] = `
|
||||
"function pug_escape(e) {
|
||||
var a = \\"\\" + e,
|
||||
t = pug_match_html.exec(a);
|
||||
if (!t) return e;
|
||||
var r,
|
||||
c,
|
||||
n,
|
||||
s = \\"\\";
|
||||
for (r = t.index, c = 0; r < a.length; r++) {
|
||||
switch (a.charCodeAt(r)) {
|
||||
case 34:
|
||||
n = \\""\\";
|
||||
break;
|
||||
case 38:
|
||||
n = \\"&\\";
|
||||
break;
|
||||
case 60:
|
||||
n = \\"<\\";
|
||||
break;
|
||||
case 62:
|
||||
n = \\">\\";
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
c !== r && (s += a.substring(c, r)), (c = r + 1), (s += n);
|
||||
}
|
||||
return c !== r ? s + a.substring(c, r) : s;
|
||||
}
|
||||
var pug_match_html = /[\\"&<>]/;
|
||||
function pug_rethrow(e, n, r, t) {
|
||||
if (!(e instanceof Error)) throw e;
|
||||
if (!((\\"undefined\\" == typeof window && n) || t))
|
||||
throw ((e.message += \\" on line \\" + r), e);
|
||||
var o, a, i, s;
|
||||
try {
|
||||
(t = t || require(\\"fs\\").readFileSync(n, { encoding: \\"utf8\\" })),
|
||||
(o = 3),
|
||||
(a = t.split(\\"\\\\n\\")),
|
||||
(i = Math.max(r - o, 0)),
|
||||
(s = Math.min(a.length, r + o));
|
||||
} catch (t) {
|
||||
return (
|
||||
(e.message += \\" - could not read from \\" + n + \\" (\\" + t.message + \\")\\"),
|
||||
void pug_rethrow(e, null, r)
|
||||
);
|
||||
}
|
||||
(o = a
|
||||
.slice(i, s)
|
||||
.map(function(e, n) {
|
||||
var t = n + i + 1;
|
||||
return (t == r ? \\" > \\" : \\" \\") + t + \\"| \\" + e;
|
||||
})
|
||||
.join(\\"\\\\n\\")),
|
||||
(e.path = n);
|
||||
try {
|
||||
e.message = (n || \\"Pug\\") + \\":\\" + r + \\"\\\\n\\" + o + \\"\\\\n\\\\n\\" + e.message;
|
||||
} catch (e) {}
|
||||
throw e;
|
||||
}
|
||||
function template(locals) {
|
||||
var pug_html = \\"\\",
|
||||
pug_mixins = {},
|
||||
pug_interp;
|
||||
var pug_debug_filename, pug_debug_line;
|
||||
try {
|
||||
var self = locals || {};
|
||||
pug_debug_line = 1;
|
||||
pug_html = pug_html + '\\\\u003Cdiv class=\\"bar\\"\\\\u003E';
|
||||
pug_debug_line = 1;
|
||||
pug_html =
|
||||
pug_html +
|
||||
pug_escape(null == (pug_interp = self.foo) ? \\"\\" : pug_interp) +
|
||||
\\"\\\\u003C\\\\u002Fdiv\\\\u003E\\";
|
||||
} catch (err) {
|
||||
pug_rethrow(err, pug_debug_filename, pug_debug_line);
|
||||
}
|
||||
return pug_html;
|
||||
}
|
||||
module.exports = template;
|
||||
"
|
||||
`;
|
||||
Reference in New Issue
Block a user