示例#1
0
// Minify minifies CSS data, it reads from r and writes to w.
func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, params map[string]string) error {
	isInline := params != nil && params["inline"] == "1"
	c := &cssMinifier{
		m: m,
		w: w,
		p: css.NewParser(r, isInline),
	}
	if err := c.minifyGrammar(); err != nil && err != io.EOF {
		return err
	}
	return nil
}
示例#2
0
// Minify minifies CSS data, it reads from r and writes to w.
func Minify(m minify.Minifier, mediatype string, w io.Writer, r io.Reader) error {
	isStylesheet := true
	if len(mediatype) >= len(";inline=0") && mediatype[len(mediatype)-len(";inline=0"):] == ";inline=1" {
		isStylesheet = false
	} else if _, params, err := mime.ParseMediaType(mediatype); err == nil && params["inline"] == "1" {
		isStylesheet = false
	}
	c := &cssMinifier{
		m: m,
		w: w,
		p: css.NewParser(r, isStylesheet),
	}

	if err := c.minifyGrammar(); err != nil && err != io.EOF {
		return err
	}
	return nil
}