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

Custom EJS files require parent EJS files to be included #70

Open
zenkimoto opened this issue Aug 11, 2022 · 1 comment
Open

Custom EJS files require parent EJS files to be included #70

zenkimoto opened this issue Aug 11, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@zenkimoto
Copy link

zenkimoto commented Aug 11, 2022

Context (Environment)

When creating a custom EJS file, you'd copy the EJS file from the layouts folder into custom/layouts. However, if the EJS file is a child EJS file (another EJS file includes it), the file doesn't get included unless the parent EJS file (the one including the child EJS) is also part of the custom/layouts folder.

Recently, there were changes to partial/search.ejs. However, the changes didn't appear in the search results screen. I had to include in the custom folder: partial/nav.ejs in order for the search changes to appear.

Expected Behavior

Use custom EJS only if the EJS file is there regardless of parent.

Actual Behavior

Includes custom EJS files only if the parent is a custom EJS file.

To Reproduce

  1. Copy an existing child EJS file and place it in the custom/layouts folder.
  2. Make some modifications to it.
  3. Launch Content Library in local development and see the code changes from step 2 do not appear.

Additional Information

This may be a problem with how the Content Library is set up or maybe it's just how EJS operates. This ticket is meant for an investigation into the issue and present a possible solution.

@zenkimoto zenkimoto added the bug Something isn't working label Aug 11, 2022
@zenkimoto
Copy link
Author

I looked into this a little bit. The EJS set up code in question is here:

https://github.com/adhocteam/nytimes-library/blob/main/server/index.js#L34-L35

This sets the EJS templates to resolve in the ./custom/layouts folder first, then resolves to ./layouts.

However, if that is the case, then I don't know why this function is needed:

https://github.com/adhocteam/nytimes-library/blob/main/server/utils.js#L12-L31

Which is what is used to fetch the top-level templates.

What I don't understand is when it goes through and resolves partials. I assume it should be using the above where the ./custom/layouts folder is resolved first. I guess if it's a partial and it's already in the ./layouts folder, it doesn't go back to the ./custom/layouts folder to resolve partials? 🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant