ventojs / vento

🌬 A template engine for Deno & Node
https://vento.js.org/
MIT License
176 stars 9 forks source link

Using `include` tag errors when using `runString` without the `file` argument set #72

Closed noelforte closed 1 month ago

noelforte commented 1 month ago

Describe the bug

When compiling a template from a string using {{ include ... }}, if the file argument of runString() is left undefined, the following error is thrown:

node:internal/modules/run_main:115
    triggerUncaughtException(
    ^

NotFound [Error]: ENOENT: no such file or directory, open 'partial.vto'
    at async open (node:internal/fs/promises:639:25)
    at async readFile (node:internal/fs/promises:1246:14)
    at async Object.readTextFile (/***/tests/vento/node_modules/.pnpm/@deno+shim-deno@0.18.2/node_modules/@deno/shim-deno/dist/deno/stable/functions/readTextFile.js:12:16)
    at async FileLoader.load (file:///***/tests/vento/node_modules/.pnpm/ventojs@0.12.6/node_modules/ventojs/esm/src/loader.js:10:21)
    at async Environment.load (file:///***/tests/vento/node_modules/.pnpm/ventojs@0.12.6/node_modules/ventojs/esm/src/environment.js:86:38)
    at async Environment.run (file:///***/tests/vento/node_modules/.pnpm/ventojs@0.12.6/node_modules/ventojs/esm/src/environment.js:18:26)
    at async eval (eval at compile (file:///***/tests/vento/node_modules/.pnpm/ventojs@0.12.6/node_modules/ventojs/esm/src/environment.js:45:29), <anonymous>:11:17)
    at async Environment.runString (file:///***/tests/vento/node_modules/.pnpm/ventojs@0.12.6/node_modules/ventojs/esm/src/environment.js:32:16)
    at async file:///***/tests/vento/test.js:10:18 {
  code: 'ENOENT'
}

To Reproduce

  1. Clone this reduced test case: https://github.com/noelforte/vento-runString-include-rtc
  2. cd to repository
  3. npm install
  4. node test.js
  5. See error

Expected behavior

Vento should be able to include files without needing the file argument to be set.

Desktop

Additional context

If the file argument has to be set for caching purposes, my use case for eleventy-plugin-vento might benefit from not having the cache to begin with (see #71).