String minifies a string (safe for concurrent use). When an error occurs it return the original string and the error. It returns an error when no such mimetype exists (ErrNotExist) or any error occurred in the minifier function.
(mediatype string, v string)
| 239 | // String minifies a string (safe for concurrent use). When an error occurs it return the original string and the error. |
| 240 | // It returns an error when no such mimetype exists (ErrNotExist) or any error occurred in the minifier function. |
| 241 | func (m *M) String(mediatype string, v string) (string, error) { |
| 242 | out := buffer.NewWriter(make([]byte, 0, len(v))) |
| 243 | if err := m.Minify(mediatype, out, buffer.NewReader([]byte(v))); err != nil { |
| 244 | return v, err |
| 245 | } |
| 246 | return string(out.Bytes()), nil |
| 247 | } |
| 248 | |
| 249 | // Reader wraps a Reader interface and minifies the stream. |
| 250 | // Errors from the minifier are returned by the reader. |