-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Specs
compile-ejs-loader: 0.0.3
webpack: 5.40.0
OS: MacOS
Issue
When trying to grab string output from
hello.ejs
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
This is <% name %>
</body>
</html>index.js
var template = require("compile-ejs-loader!./hello.ejs");
const result = template({ name: 'john doe' });
console.log(result);I got this in the console
module.exports = function anonymous(locals, escapeFn, include, rethrow) {
rethrow = rethrow || function rethrow(err, str, flnm, lineno, esc) {
var lines = str.split("\n");
var start = Math.max(lineno - 3, 0);
var end = Math.min(lines.length, lineno + 3);
var filename = esc(flnm);
var context = lines.slice(start, end).map(function(line, i) {
var curr = i + start + 1;
return (curr == lineno ? " >> " : " ") + curr + "| " + line;
}).join("\n");
err.path = filename;
err.message = (filename || "ejs") + ":" + lineno + "\n" + context + "\n\n" + err.message;
throw err;
};
escapeFn = escapeFn || function(markup) {
return markup == undefined ? "" : String(markup).replace(_MATCH_HTML, encode_char);
};
var _ENCODE_HTML_RULES = {
"&": "&",
"<": "<",
">": ">",
'"': """,
"'": "'"
}, _MATCH_HTML = /[&<>'"]/g;
function encode_char(c) {
return _ENCODE_HTML_RULES[c] || c;
}
var __line = 1, __lines = '<!DOCTYPE html>\n<html lang="en">\n<head>\n <meta charset="UTF-8">\n <meta http-equiv="X-UA-Compatible" content="IE=edge">\n <meta name="viewport" content="width=device-width,initial-scale=1">\n <title>Document</title>\n</head>\n<body>\n This is \n</body>\n</html>', __filename = "src/hello.ejs";
try {
var __output = "";
function __append(s) {
if (s !== undefined && s !== null) __output += s;
}
with (locals || {}) {
__append('<!DOCTYPE html>\n<html lang="en">\n<head>\n <meta charset="UTF-8">\n <meta http-equiv="X-UA-Compatible" content="IE=edge">\n <meta name="viewport" content="width=device-width,initial-scale=1">\n <title>Document</title>\n</head>\n<body>\n This is ');
__line = 10;
name;
__append("\n</body>\n</html>");
__line = 12;
}
return __output;
} catch (e) {
rethrow(e, __lines, __filename, __line, escapeFn);
}
}shouldn't it suppose to return the string?
Thank you 🙂
Screenshot
Metadata
Metadata
Assignees
Labels
No labels
