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



Copy link

epiqueras commented Feb 14, 2020

Closes #20201


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.


  • 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 requested a review from TimothyBJacobs as a code owner Feb 14, 2020
@epiqueras epiqueras self-assigned this Feb 14, 2020

This comment has been minimized.

Copy link
Contributor Author

epiqueras commented Feb 17, 2020

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

mtias approved these changes Feb 17, 2020
@epiqueras epiqueras merged commit 28c49ae into master Feb 17, 2020
3 checks passed
3 checks passed
Travis CI - Pull Request Build Passed
@epiqueras epiqueras added this to Done in Phase 2 via automation Feb 17, 2020
@epiqueras epiqueras deleted the fix/show-error-when-resolved-block-template-is-empty branch Feb 17, 2020
@@ -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;

This comment has been minimized.

Copy link

johnstonphilip Feb 17, 2020


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

This comment has been minimized.

Copy link

epiqueras Feb 17, 2020

Author Contributor
epiqueras added a commit that referenced this pull request Feb 17, 2020
epiqueras added a commit that referenced this pull request Feb 18, 2020
epiqueras added a commit that referenced this pull request Feb 18, 2020
@youknowriad youknowriad modified the milestones: Future, Gutenberg 7.6 Feb 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Phase 2
Linked issues

Successfully merging this pull request may close these issues.

4 participants
You can’t perform that action at this time.