Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Converter ¶
type Converter struct {
// contains filtered or unexported fields
}
Converter does processing of CSS input files and writes a single output CSS file with the appropriate @ directives processed. Inputs are processed in the order they are added (see e.g. AddReader()).
func New ¶
New returns an initialized instance of Converter. The out param indicates where output is written, it must not be nil.
func (*Converter) AddReader ¶
AddReader adds an input source. The name is used only in error messages to indicate the source. And r is the CSS source to be processed, it must not be nil. If isInline it indicates this CSS is from an HTML style attribute, otherwise it's from the contents of a style tag or a standlone CSS file.
func (*Converter) Run ¶
Run performs the conversion. The output is written to the writer specified in New().
func (*Converter) SetPostProcFunc ¶
SetPostProcFunc sets the function that is called to post-process the output of the converter. The typical use of this is for minification.
Example ¶
var buf bytes.Buffer conv := tailwind.New(&buf, twembed.New()) conv.SetPostProcFunc(func(out io.Writer, in io.Reader) error { m := minify.New() m.AddFunc("text/css", css.Minify) return m.Minify("text/css", out, in) }) conv.AddReader("input.css", strings.NewReader(`.test1 { @apply font-bold; }`), false) err := conv.Run() if err != nil { panic(err) } fmt.Printf("%s", buf.String()) // notice the missing trailing semicolon
Output: .test1{font-weight:700}
func (*Converter) SetPurgeChecker ¶
func (c *Converter) SetPurgeChecker(purgeChecker PurgeChecker)
type Dist ¶
type Dist interface { // OpenDist should return a new ReadCloser for the specific tailwind section name. // Valid names are "base", "utilities" and "components" (only those exact strings, // without .css or anything like that) and will be updated along with // what the TailwindCSS project does. The caller is responsible for ensuring // Close() is called on the response if the error is non-nil. OpenDist(name string) (io.ReadCloser, error) }
Dist is where tailwind CSS data can be read.
type PurgeChecker ¶
PurgeChecker is something which can tell us if a key should be purged from the final output (because it is not used). See package twpurge for default implementation.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
Package twembed contains an embedded copy of the TailwindCSS distribution.
|
Package twembed contains an embedded copy of the TailwindCSS distribution. |
Package twfiles implements tailwind.Dist against a filesystem.
|
Package twfiles implements tailwind.Dist against a filesystem. |
Package twhandler provides an HTTP handler that performs processing on CSS files and serves them.
|
Package twhandler provides an HTTP handler that performs processing on CSS files and serves them. |