eta icon indicating copy to clipboard operation
eta copied to clipboard

feat: expose resolvePath to templates

Open aranor01 opened this issue 1 year ago • 1 comments

This PR adds resolvePath to transform relative paths into absolute ones. A use case for this is dynamic import, e.g.:

<% let utils = await import (resolvePath("./include/utils.mjs")) %>

The lack of this feature can be worked around by exposing Eta.resolvePath via it. However, if used in a partial, the base path used to resolve the relative path would always be the directory of the including (root) template, which could lead to confusion.

aranor01 avatar Mar 09 '25 20:03 aranor01

@aranor01 thanks for the PR! Your reasoning makes sense, but I'm not sure how common a use case this is. In the meantime, you can just put that value in config.functionHeader!

I'll leave this open to gauge interest.

bgub avatar Mar 21 '25 04:03 bgub

Closing for now since it seems like there hasn't been a lot of interest, with the possibility of reopening in the future.

bgub avatar Nov 12 '25 22:11 bgub