Skip to content

strip superfluous spaces from class lists #1074

Open
@romshark

Description

Consider the following snippet from a templ template:

<div
	class="
		flex w-full h-full
		justify-center items-center
		hover:bg-blue-50
	"
>

I often follow this styling to avoid putting very long lists of classes in a single line:

<div
	class="flex w-full h-full justify-center items-center hover:bg-blue-50"
>

The length of real class lists in my code is often several times longer.

templ v0.3.833 generates the following Go code:

<div class=\"\n\t\t\t\t\t\t\tflex w-full h-full\n\t\t\t\t\t\t\tjustify-center items-center\n\t\t\t\t\t\t\thover:bg-blue-50\n\t\t\t\t\t\t\">

I believe these line-breaks and tabs serve no purpose and can be stripped.

  • This would reduce the size of the generated HTML at runtime.
  • ...and make generated code smaller and easier to read.
<div class=\"flex w-full h-full justify-center items-center hover:bg-blue-50\">

https://go.dev/play/p/ejEBGL99OAf

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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