Skip to content

feat: expose resolvePath to templates #304

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aranor01
Copy link

@aranor01 aranor01 commented Mar 9, 2025

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.

@bgub
Copy link
Collaborator

bgub commented Mar 21, 2025

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants