-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regression of file loading outside of template location #29
Comments
Pug4J needs a Base path, so that it can determine the parent path. By default the basePath is empty.
Pug is now allowed to read all files below /root/dir/ but not in / and /root |
You can't set a base path if you use There are many confusing things about the API (The code has a templateLoaderPath and a basePath and wants to load a template with a name that appears to just be a filename but without an extension?? You ask a config object to get and render templates? The rootpath must be absolute?), but the real issue is that your code example appears to just not work at all. With your code I now get a NoSuchFileException for a path that doesn't include the basepath. The code appears to ignore the basepath when looking for files. Code is here. This is the error:
|
Ok. I had the documentation wrong. What I found out, is you need to add a "/" in front of our "index" template name. This will select the base folder. Otherwise only the templateLoaderPath is used. private static String toBaseName(final Path file) {
final String filename = file.getFileName().toString();
return "/"+filename;
} Then it prints out: <html lang="en-US"><head><title>Skeleton</title><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"/><link rel="stylesheet" href="../webinc/style.css" inline="inline" compress="compress"/><script id="page" type="text/html" compress="compress"><p>I am an html page</p></script></head><body id="canvas"><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script><script src="../webinc/js/before.js" inline="inline" compress="compress"></script><script type="text/javascript" compress="compress">function page() {
console.log('Page!');
}</script><script src="../webinc/js/after.js" inline="inline" compress="compress"></script></body></html> |
Yeah the forward slash works. The bug-repo is now out of date since the problem is solved so I'm going to set it as private. Thanks. |
The bug described in issue 3 has come back. Every version from 2.0.5 onwards now fails with the 'The template [../webinc/skeleton.pug] could not be opened. Maybe outside template path.' error.
The text was updated successfully, but these errors were encountered: