-
Notifications
You must be signed in to change notification settings - Fork 326
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
base: main
Are you sure you want to change the base?
Image customization: add include() function #3148
Conversation
57dc935
to
fa09986
Compare
@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 👍 |
Makes sense, I wanted to add more examples to the image customization docs anyways. |
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. |
I think there is no hurry regarding this PR, and I can work on the doc examples in the next days. |
fa09986
to
7de7e58
Compare
$(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.
7de7e58
to
1e1f269
Compare
I have rebased and extended the PR with various examples, as well as some additional error checks. |
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