Open byteslaves opened 3 months ago
I've pinpointed the code causing the issue and modified it within the module I'm using. Now, the art-template template engine is working as expected. I'm not entirely sure if there are any unintended side effects from this change, as I haven't delved too deeply into the module's overall mechanics. The modified line, number 415, is: // confs.filename = join(templatesDir, filename) confs.filename = filename
Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.
Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.
I apologize, but as I'm just starting to learn how to use Fastify, I may not be able to submit a pull request to resolve this issue right now.
Prerequisites
Fastify version
4.28.1
Plugin version
9.1.0
Node.js version
20
Operating system
Windows
Operating system version (i.e. 20.04, 11.3, 10)
win11
Description
Upon employing this plugin, utilizing art-template as the template engine, and assigning a path to the root property, an error ensues due to the unintended concatenation of two paths during the rendering process. This behavior is not observed when using the EJS template engine.
The relevant code snippet is provided below:
fastify.register(fastifyView, { engine: { 'art-template': require('art-template') }, root:'./views/rat/' })
fastify.get("/art", (req, reply) => { reply.view('./index.art', { text: "text" }); });
error message: err: { "type": "Error", "message": "template not found: ENOENT: no such file or directory, open 'S:\user\js-ts-project\fastify\hello-world\views\rat\views\rat\index.art'", "stack": TemplateError: template not found: ENOENT: no such file or directory, open 'S:\user\js-ts-project\fastify\hello-world\views\rat\views\rat\index.art' "name": "TemplateError" }
Big thanks to all the Fastify contributors!
Link to code that reproduces the bug
No response
Expected Behavior
Can access the directory correctly