[wp-trac] [WordPress Trac] #55930: Provide comment syntax for templates and template parts

WordPress Trac noreply at wordpress.org
Mon Jun 6 05:59:02 UTC 2022


#55930: Provide comment syntax for templates and template parts
----------------------------+-----------------------------
 Reporter:  wprediscovered  |      Owner:  (none)
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  General         |    Version:  6.0
 Severity:  minor           |   Keywords:
  Focuses:                  |
----------------------------+-----------------------------
 ''Thanks to all of you for working on this great Free Software project! ''

 I'm trying to add copyright and license information to my theme. I do so
 using SPDX headers using REUSE tool [https://reuse.software]. This adds
 information to the `.html` files using HTML comments (`<!--` ... `-->`).

 The **Site Editor** in **WordPress 6.0** doesn't seem able to handle with
 regular HTML comments in templates and template parts.

 On a new theme created using `new-empty-theme.php` this results in the
 following `index.html` page for example:

 {{{
 <!--
 SPDX-FileCopyrightText: 2019-2022 WordPress Theme Experiments contributors

 SPDX-License-Identifier: GPL-2.0-or-later
 -->

 <!-- wp:template-part {"slug":"header","tagName":"header"} /-->

 <!-- wp:query
 {"queryId":1,"query":{"offset":0,"postType":"post","categoryIds":[],"tagIds":[],"order":"desc","orderBy":"date","author":"","search":"","sticky":""}}
 -->
 <!-- wp:post-template -->
 <!-- wp:post-title {"isLink":true} /-->

 <!-- wp:post-excerpt /-->
 <!-- /wp:post-template -->
 <!-- /wp:query -->
 }}}

 It renders just fine, but in the Site Editor these comments of templates
 and template parts get treated as blocks. This results in an error for
 each template and page template that has the HTML annotations: "**This
 block has encountered an error and cannot be previewed.**''''"

 [[Image(https://user-
 images.githubusercontent.com/7458098/172100897-8fdc7d30-13c1-443d-b951-d9d004c73118.png)]]

 Copying the block contents (source code) the resulting output is as
 follows:

 {{{
 <p><!--
 SPDX-FileCopyrightText: 2019-2022 WordPress Theme Experiments contributors

 SPDX-License-Identifier: GPL-2.0-or-later
 --></p>
 }}}

 So it seems that the comment is treated as a paragraph.

 Besides this being valid HTML, I couldn't find anything about a separate
 comment syntax in the [https://developer.wordpress.org/themes/block-themes
 /templates-and-template-parts/] documentation.

 **I expect the Site Editor to ignore non-wp comments rather than trying to
 parse them as blocks.**

 ''I documented some other experiences with using REUSE on WordPress themes
 in an issue at the REUSE project: [https://github.com/fsfe/reuse-
 tool/issues/537]''

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/55930>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list