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

Empty Block Templates output string on front-end stating "Empty Template". #20276

Closed
johnstonphilip opened this issue Feb 17, 2020 · 3 comments · Fixed by #30145
Closed

Empty Block Templates output string on front-end stating "Empty Template". #20276

johnstonphilip opened this issue Feb 17, 2020 · 3 comments · Fixed by #30145
Assignees
Labels
[Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.

Comments

@johnstonphilip
Copy link
Contributor

johnstonphilip commented Feb 17, 2020

Describe the bug
If a block template has no content in post_content, instead of seeing a blank page (which would match the template), a string is output on the front-end stating "Empty Template", even for logged-out users.

Screen Shot 2020-02-17 at 4 42 30 PM

To reproduce
Steps to reproduce the behavior:

  1. On a fresh install, create a Block Based Theme with just a single.html file, and put no content in that file.
  2. View the "Hello World" post.
  3. See the message that states "Empty template.".
  4. Log out.
  5. Notice you still see that message.

Expected behavior
I would expect 2 things here:

  • If logged-out, I would expect to see a blank page on the front-end, which matches the template.
  • If logged-in with admin-level capabilities, an error might appear stating "The single.html template was blank", thought this is likely better shown in wp-admin, rather than on the front-end.

Desktop (please complete the following information):

  • OS: MacOS Catalina
  • Browser: Chrome
  • Version 79.0.3945.130 (Official Build) (64-bit)

Additional context
The code for this is happening here:

$_wp_current_template_content = empty( $current_template['template_post']->post_content ) ? __( 'Empty template.', 'gutenberg' ) : $current_template['template_post']->post_content;

  • Gutenberg version: master.
@johnstonphilip
Copy link
Contributor Author

A similar problem occurs with template-parts that are empty:

See where a string is returned if a blank template part is found here:

return 'Template Part Not Found';

One additional aside thing is that that message is untranslated.

@talldan talldan added [Feature] Full Site Editing Needs Testing Needs further testing to be confirmed. labels Feb 18, 2020
@johnstonphilip
Copy link
Contributor Author

One other related issue here is this:

  • Create a block template called front-page
  • Add a template part, and make it call footer
  • Don't place anything in the footer template-part.

You will not get the error message that is intended to show, but a blank page, as the output on the page is simply this:

<!-- wp:template-part {"postId":141,"slug":"footer","theme":"my-theme"} /-->

Since that is not empty, you don't get the error message that was intended.

@talldan talldan added [Type] Enhancement A suggestion for improvement. and removed Needs Testing Needs further testing to be confirmed. labels Jul 21, 2020
@carolinan
Copy link
Contributor

For template parts, this can be solved with #28398

@carolinan carolinan self-assigned this Mar 23, 2021
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Mar 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants