Skip to content

proposal: Go comments within HTML tags #866

@romshark

Description

@romshark

In addition to #79, I'd like to propose // comments within HTML tags, such as:

<form
  class="flex"
  // This comment here explains why the following attribute is necessary,
  // namely to prevent submit when hitting the enter key.
  // But templ won't allow this comment to be here and throws syntax errors.
  action="javascript:void(0)"
>

image

Current Workaround

Currently, the comments must be put above the HTML tag, which is not always convenient.

// Use action="javascript:void(0)" to prevent submit on enter
<form
  class="flex"
  action="javascript:void(0)"
>

Since // is not a valid token inside an HTML tag IMHO it should be possible to allow Go comments within tags that aren't included in the compiled HTML.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions