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

Lib: Show error when resolved block template is empty. #20239

Merged

Conversation

epiqueras
Copy link
Contributor

Closes #20201

Description

When a resolved block template was empty, the "No matching template found." error message was displayed. This was confusing to users because a template was found; it was just empty.

This PR handles these cases with an "Empty template." error message instead.

How to test this?

  • Enable The Gutenberg FSE and Demo Templates Experiments.
  • Visit your home page and verify the demo front-page template is rendering.
  • Delete the contents of lib/demo-block-templates/front-page.html.
  • Refresh your home page and verify that the "Empty template." message is displayed.

Types of Changes

New Feature: There is now a more granular error message to differentiate between when a block template is not found and when a block template is found, but it is empty.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

@epiqueras epiqueras added this to the Future milestone Feb 14, 2020
@epiqueras epiqueras self-assigned this Feb 14, 2020
@epiqueras
Copy link
Contributor Author

@WordPress/gutenberg-core Can we get this merged? It's a solid change regardless of how design decides to handle this later on.

@epiqueras epiqueras merged commit 28c49ae into master Feb 17, 2020
@epiqueras epiqueras deleted the fix/show-error-when-resolved-block-template-is-empty branch February 17, 2020 20:10
@@ -199,7 +199,7 @@ function gutenberg_find_template( $template_file ) {
}
}
$_wp_current_template_id = $current_template_post->ID;
$_wp_current_template_content = $current_template_post->post_content;
$_wp_current_template_content = empty( $current_template_post->post_content ) ? 'Empty template.' : $current_template_post->post_content;
Copy link
Contributor

Choose a reason for hiding this comment

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

@epiqueras This string should likely be wrapped in a translation function like __(.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

Empty templates in Block Based Themes result in "No matching template found" message.
4 participants