28 lines
598 B
Go
28 lines
598 B
Go
package slice
|
|
|
|
import "html/template"
|
|
import "github.com/gabriel-vasile/mimetype"
|
|
import "git.tebibyte.media/sashakoshka/step"
|
|
|
|
const hiddenPrefix = "."
|
|
|
|
var _ step.FuncProvider = new(Provider)
|
|
|
|
// Provider provides MIME functions.
|
|
type Provider struct {
|
|
|
|
}
|
|
|
|
// FuncMap fulfills the step.FuncProvider interface.
|
|
func (this *Provider) FuncMap () template.FuncMap {
|
|
return template.FuncMap {
|
|
"fileContentType": funcFileContentType,
|
|
}
|
|
}
|
|
|
|
func funcFileContentType (name string) (string, error) {
|
|
typ, err := mimetype.DetectFile(name)
|
|
if err != nil { return "", err }
|
|
return typ.String(), err
|
|
}
|