Documentation ¶
Overview ¶
Package vugufmt provides gofmt-like functionality for vugu files.
Index ¶
- func UseGoFmt(simplifyAST bool) func(*Formatter)
- func UseGoImports(f *Formatter)
- type FmtError
- type Formatter
- func (f *Formatter) Diff(filename string, input io.Reader, output io.Writer) (bool, error)
- func (f *Formatter) FormatHTML(filename string, in io.Reader, out io.Writer) error
- func (f *Formatter) FormatScript(scriptType string, scriptContent []byte) ([]byte, *FmtError)
- func (f *Formatter) FormatStyle(styleContent []byte) ([]byte, *FmtError)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UseGoFmt ¶
UseGoFmt sets the formatter to use gofmt on x-go blocks. Set simplifyAST to true to simplify the AST. This is false by default for gofmt, and is the same as passing in -s for it.
func UseGoImports ¶
func UseGoImports(f *Formatter)
UseGoImports sets the formatter to use goimports on x-go blocks.
Types ¶
type Formatter ¶
type Formatter struct { // ScriptFormatters maps script blocks to formatting // functions. // For each type of script block, // we can run it through the supplied function. // If the function returns error, we should // not accept the output written to the writer. // You can add your own custom one for JS, for // example. If you want to use gofmt or goimports, // see how to apply options in NewFormatter. ScriptFormatters map[string]func([]byte) ([]byte, *FmtError) // StyleFormatter handles CSS blocks. StyleFormatter func([]byte) ([]byte, *FmtError) }
Formatter allows you to format vugu files.
func NewFormatter ¶
NewFormatter creates a new formatter. Pass in vugufmt.UseGoFmt to use gofmt. Pass in vugufmt.UseGoImports to use goimports.
func (*Formatter) Diff ¶
Diff will show differences between input and what Format() would do. It will return (true, nil) if there is a difference, (false, nil) if there is no difference, and (*, notnil) when the difference can't be determined. filename is optional, but helps with generating useful output.
func (*Formatter) FormatHTML ¶
FormatHTML formats script and css nodes.
func (*Formatter) FormatScript ¶
FormatScript formats script text nodes.