Documentation ¶
Index ¶
- func ApplyToHTMLText(doc []byte, fn func(string) string) []byte
- func CopyFileContents(dst, src string, perm os.FileMode) error
- func FollowDots(data interface{}, props []string) (interface{}, error)
- func IsNotEmpty(err error) bool
- func LeftPad(s string, n int) string
- func MatchList(patterns []string, name string) bool
- func MergeStringMaps(ms ...map[string]interface{}) map[string]interface{}
- func MustAbs(path string) string
- func MustRel(basepath, targpath string) string
- func NewPathError(op, name, text string) *os.PathError
- func ParseFilenameDateTitle(s string) (t time.Time, title string, found bool)
- func PostfixWalk(root string, walkFn filepath.WalkFunc) error
- func ReadFileMagic(filename string) ([]byte, error)
- func RemoveEmptyDirectories(root string) error
- func SafeReplaceAllStringFunc(re *regexp.Regexp, src string, repl func(m string) (string, error)) (out string, err error)
- func SearchStrings(array []string, s string) bool
- func Slugify(s string) string
- func StringArrayContains(a []string, s string) bool
- func StringArrayToMap(a []string) map[string]bool
- func Titleize(s string) string
- func TrimExt(name string) string
- func URLJoin(paths ...string) string
- func URLPathClean(url string) string
- func UnmarshalYAMLInterface(b []byte, i *interface{}) error
- func VisitCreatedFile(filename string, w func(io.Writer) error) (err error)
- func WrapError(err error, m string) error
- func WrapPathError(err error, path string) error
- type PathError
- type StringList
- type StringSet
- type WrappedError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyToHTMLText ¶
ApplyToHTMLText applies a filter only to the text within an HTML document.
func CopyFileContents ¶
CopyFileContents copies the file contents from src to dst. It's not atomic and doesn't copy permissions or metadata.
func FollowDots ¶
FollowDots applied to a property list ["a", "b", "c"] is equivalent to the Liquid data expression "data.a.b.c", except without special treatment of "first", "last", and "size".
func IsNotEmpty ¶
IsNotEmpty returns a boolean indicating whether the error is known to report that a directory is not empty.
func LeftPad ¶
LeftPad left-pads s with spaces to n wide. It's an alternative to http://left-pad.io.
func MatchList ¶ added in v0.1.0
MatchList implement Jekyll include: and exclude: configurations. It reports whether any glob pattern matches the path. It panics with ErrBadPattern if any pattern is malformed. To match Jekyll, a string "dir/" matches that begins with this prefix.
func MergeStringMaps ¶
MergeStringMaps creates a new variable map that merges its arguments, from first to last.
func NewPathError ¶
NewPathError returns an os.PathError that formats as the given text.
func ParseFilenameDateTitle ¶ added in v0.2.7
ParseFilenameDateTitle returns the date for a filename that uses Jekyll post convention. It also returns a bool indicating whether a date was found.
func PostfixWalk ¶
PostfixWalk is like filepath.Walk, but visits each directory after visiting its children instead of before. It does not implement SkipDir.
func ReadFileMagic ¶
ReadFileMagic returns the first four bytes of the file, with final '\r' replaced by '\n'.
func RemoveEmptyDirectories ¶
RemoveEmptyDirectories recursively removes empty directories.
func SafeReplaceAllStringFunc ¶
func SafeReplaceAllStringFunc(re *regexp.Regexp, src string, repl func(m string) (string, error)) (out string, err error)
SafeReplaceAllStringFunc is like regexp.ReplaceAllStringFunc but passes an an error back from the replacement function.
func SearchStrings ¶
SearchStrings returns a bool indicating whether array contains the string. Unlike sort.SearchStrings, it does not require a sorted array. This is useful when the array length is low; else consider sorting it and using sort.SearchStrings, or creating a map[string]bool.
func StringArrayContains ¶ added in v0.2.7
StringArrayContains returns a bool indicating whether the array contains the string.
func StringArrayToMap ¶
StringArrayToMap creates a map for use as a set.
func URLPathClean ¶
URLPathClean removes internal // etc. Unlike path.Clean, it leaves the final "/" intact.
func UnmarshalYAMLInterface ¶
UnmarshalYAMLInterface is a wrapper for yaml.Unmarshal that knows how to unmarshal maps and lists.
func VisitCreatedFile ¶
VisitCreatedFile calls os.Create to create a file, and applies w to it.
func WrapError ¶ added in v0.2.7
WrapError returns an error decorated with a message. If the error is nil, it returns nil.
func WrapPathError ¶
WrapPathError returns an error that will print with a path.\ It wraps its argument if it is not nil and does not already provide a path.
Types ¶
type PathError ¶
type PathError interface { WrappedError Path() string }
A PathError is an error with a source path.
An os.PathError is unfortunately not a PathError, but this is still useful for deciding whether to wrap other errors.
type StringList ¶ added in v0.2.7
type StringList []string
StringList adds methods to []string
func (StringList) Reject ¶ added in v0.2.7
func (sl StringList) Reject(p func(string) bool) StringList
Reject returns a copy of StringList without elements that its argument tests true on.
type StringSet ¶ added in v0.2.0
A StringSet is a set of strings, represented as a map.
func MakeStringSet ¶ added in v0.2.7
MakeStringSet creates a characteristic function map that tests for presence in an array.
func (StringSet) AddStrings ¶ added in v0.2.7
AddStrings modifies the set to include the strings in an array.
type WrappedError ¶ added in v0.2.7
A WrappedError decorates an error with a message