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

Add default template warning #2205

Open
wants to merge 8 commits into
base: next
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
cargo fmt
  • Loading branch information
Raymi306 committed May 1, 2023
commit 10123404affa5dadd0e724fe88ddb4253ceef7a4
2 changes: 1 addition & 1 deletion components/utils/src/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub fn render_template(
}

pub fn is_default_template(name: &str, tera: &Tera, theme: &Option<String>) -> Result<bool> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

That's not the right place to check. You essentially need to search for templates with that name in a theme or the templates directory Tera instances. Only if there are no overrides should the message be shown. Another way to do it would be to have a log Tera functions that does println so the template itself can warn

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You essentially need to search for templates with that name in a theme or the templates directory Tera instances. Only if there are no overrides should the message be shown.

Sorry, I thought I had accomplished this with this function which uses check_template_fallbacks. I will think on this but I am currently confused as to how to do this differently without repeating the logic in check_template_fallbacks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How do I do this without repeating logic in check_template_fallbacks?

if check_template_fallbacks(name, tera, theme).is_some() {
if check_template_fallbacks(name, tera, theme).is_some() {
return Ok(false);
}
match name {
Expand Down