Skip to content

feat: add include_optional template function for content #861

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

Conversation

marevers
Copy link

@marevers marevers commented Jul 8, 2025

Description of your changes

Fixes #599

This adds a new template function to content called include_optional. The regular include function expects the file to exist and will panic if it doesn't. With this new function, you can provide a fallback value (or an empty string) that will be returned if the file is not found.

Example:

{{ include_optional "path/to/file" "File does not exist" }}

I have:

How has this code been tested

Tested by running make test.

marevers added 2 commits July 8, 2025 14:58
Signed-off-by: Martijn Evers <mevers@gk-software.com>
Signed-off-by: Martijn Evers <mevers@gk-software.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optional include statement
1 participant