Skip to content

Image customization: add include() function #3148

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 5 commits into
base: main
Choose a base branch
from

Conversation

neocturne
Copy link
Member

Add a simple way to include image customization Lua snippets.
Can be used to split long files, to include the same options multiple
times in different conditional branches, or even to pass values back to
the including file using return.

Relative paths are interpreted relative to the site root (where
image-customization.lua is located). Relative includes would become
confusing when subdirectories are involved (as they are still interpreted
relative to the site root, and proper tracking of current directory for
each include seems fairly complex for a very niche use case), so we simply
reject this case for now; this way, we can implement this however we
want in the future if deemed necessary, without a breaking change.

Suggested by @T-X

@neocturne neocturne requested a review from blocktrron January 5, 2024 11:12
@neocturne neocturne force-pushed the image-customization-include branch from 57dc935 to fa09986 Compare January 5, 2024 11:14
@github-actions github-actions bot added 3. topic: docs Topic: Documentation 3. topic: build This is about the build system labels Jan 5, 2024
@blocktrron
Copy link
Member

@neocturne Would you mind implementing a sample implementation for the example-site? From the documentation one could assume it works similar to sourcing a shell-script. I think an example is the best way of demonstrating a best-practice use.

The implementation itself looks good 👍

@neocturne
Copy link
Member Author

Makes sense, I wanted to add more examples to the image customization docs anyways.

@blocktrron
Copy link
Member

Shall we wait for these to arrive? I think the PR itself is fine as-is. I'd just wait for a backport to v2023.2 for docs.

@neocturne
Copy link
Member Author

neocturne commented Jan 7, 2024

I think there is no hurry regarding this PR, and I can work on the doc examples in the next days.

$(error ...) already adds a `.` to the end of error messages.
Make the example match our recommended coding style.
Add usage examples, and simply the wording in a few cases.
Also make our messages match standard errors generated by Lua by
starting with a lowercase letter.
Add a simple way to include image customization Lua snippets.
Can be used to split long files, to include the same options multiple
times in different conditional branches, or even to pass values back to
the including file using return.

Relative paths are interpreted relative to the site root (where
image-customization.lua is located). Relative includes would become
confusing when subdirectories are involved (as they are still interpreted
relative to the site root, and proper tracking of current directory for
each include seems fairly complex for a very niche use case), so we simply
reject this case for now; this way, we can implement this however we
want in the future if deemed necessary, without a breaking change.
@neocturne neocturne force-pushed the image-customization-include branch from 7de7e58 to 1e1f269 Compare March 24, 2025 18:15
@neocturne
Copy link
Member Author

I have rebased and extended the PR with various examples, as well as some additional error checks.

@neocturne neocturne added 2. status: waiting-on-review Awaiting review from the assignee but also interested parties. and removed 2. status: waiting-on-author Waiting on some action from the author labels Mar 24, 2025
@blocktrron blocktrron self-assigned this Mar 25, 2025
@neocturne neocturne added this to the v2025.1 milestone Mar 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2. status: waiting-on-review Awaiting review from the assignee but also interested parties. 3. topic: build This is about the build system 3. topic: docs Topic: Documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants