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

Allow empty templates dir #2153

Closed

Conversation

iwahbe
Copy link

@iwahbe iwahbe commented Mar 26, 2023

IMPORTANT: Please do not create a Pull Request adding a new feature without discussing it first.

The place to discuss new features is the forum: https://zola.discourse.group/
If you want to add a new feature, please open a thread there first in the feature requests section.

Sanity check:

  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Code changes

(Delete or ignore this section for documentation changes)

  • Are you doing the PR on the next branch?

If the change is a new feature or adding to/changing an existing one:

  • Have you created/updated the relevant documentation page(s)?

This will fix #2150.

@iwahbe iwahbe force-pushed the iwahbe/2150/allow-empty-templates-dir branch 2 times, most recently from 707345d to aa72263 Compare March 26, 2023 17:46
@@ -47,8 +47,15 @@ pub fn load_tera(path: &Path, config: &Config) -> Result<Tera> {

// Only parsing as we might be extending templates from themes and that would error
// as we haven't loaded them yet
let mut tera =
Tera::parse(&tpl_glob).context("Error parsing templates from the /templates directory")?;
let mut tera = match Tera::parse(&tpl_glob) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have the path from above. We can just join templates and see if it exists. If it does then we load Tera with the glob otherwise Tera::default()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be a little more straight forward.

@iwahbe iwahbe force-pushed the iwahbe/2150/allow-empty-templates-dir branch from c77dfe2 to 7b2ae17 Compare March 27, 2023 09:03
@iwahbe iwahbe requested a review from Keats March 27, 2023 09:04
@vimpostor
Copy link

vimpostor commented Apr 5, 2023

I still believe this issue is best fixed on tera's side. If you look at the bottom of Keats/tera#819, you can already see quite an enormous amount of reverse references to repos where this change caused a regression.

@Keats Perhaps it is best to rethink this and to allow globs over non-existing directories to return the empty set again. After all this is how it is done in most of other languages and sometimes following widely established conventions is more important than a personal strong opinion about some behaviour. ;)

@Keats
Copy link
Collaborator

Keats commented Apr 5, 2023

We can fix it in Tera, I didn't see the number of reverse mentions

@cwkang1998
Copy link

Hey, encountering issues with this. Since tera had already fixed and merged this in (and i believe its published with the latest version of tera), can we upgrade tera to latest to address the issue?

@Keats
Copy link
Collaborator

Keats commented Aug 22, 2023

It's already upgraded in the next branch

@Keats Keats closed this Aug 22, 2023
@cwkang1998
Copy link

Currently still having issues with 0.17.2 on CI, is it scheduled for the next release?

@vimpostor
Copy link

vimpostor commented Aug 22, 2023

Currently zola is still using tera 1.18.1, which is the problematic version:

zola/Cargo.lock

Line 3537 in 9ae7d15

version = "1.18.1"

You need to upgrade to tera 1.19.0 by running cargo update. Then afterwards make a zola release, so that the version with the fix can be used in CI and in distros.

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

Successfully merging this pull request may close these issues.

[Regression] Doesn't build without top-level templates directory
4 participants