Skip to content
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

(Jinja2) Relative file include does not work as expected #78

Open
Yoshi325 opened this issue Oct 27, 2023 · 0 comments
Open

(Jinja2) Relative file include does not work as expected #78

Yoshi325 opened this issue Oct 27, 2023 · 0 comments

Comments

@Yoshi325
Copy link

Yoshi325 commented Oct 27, 2023

  • pypugjs version: 5.9.12
  • Django version: N/A
  • Flask version: 2.3.3
  • Jinja2 version: 3.1.2
  • Python version: 3.11
  • Operating System: (at least) macOS and Linux

Description

I attempted to include a file relative to the current file. PugJS states (https://pugjs.org/language/includes.html):

If the path is absolute (e.g., include /root.pug), it is resolved by prepending options.basedir. Otherwise, paths are resolved relative to the current file being compiled.

If no file extension is given, .pug is automatically appended to the file name.

However, the code here:

def visitInclude(self, node):
path = os.path.join(
self.options.get("basedir", '.'), self.format_path(node.path)
)
if os.path.exists(path):
src = open(path, 'r').read()
else:
raise Exception("Include path doesn't exists ({})".format(path))

always prepends the basedir option if it is set.

I believe this should be changed to match what is stated.

@Yoshi325 Yoshi325 changed the title (Jinja2) Relative file import does not work as expected (Jinja2) Relative file include does not work as expected Oct 27, 2023
Yoshi325 added a commit to Yoshi325/pypugjs that referenced this issue Oct 27, 2023
Also fixes non-pug includes (they were being parsed as pug).

Issue kakulukia#78
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

No branches or pull requests

1 participant