format

package
v0.3.977 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 31, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ScriptElement

func ScriptElement(se *parser.ScriptElement, depth int, prettierCommand string) (err error)

ScriptElement formats a ScriptElement node, replacing Go expressions with placeholders for formatting. After formatting, it updates the GoCode expressions and their ranges.

func StyleElement

func StyleElement(se *parser.RawElement, depth int, prettierCommand string) (err error)

func Templ

func Templ(src []byte, fileName string, config Config) (output []byte, changed bool, err error)

Templ formats templ source, returning the formatted output, whether it changed, and an error if any. The fileName is used for Go import processing, use an empty name if the source is not from a file.

Types

type Config

type Config struct {
	// PrettierCommand is the command to run to format the content of script and style elements.
	// If empty, the default is "prettier --use-tabs --stdin-filepath $TEMPL_PRETTIER_FILENAME".
	PrettierCommand string
	// PrettierRequired indicates that formatting using Prettier must be applied.
	PrettierRequired bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL