assets

package
v2.0.3+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2017 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseDirWithExt

func ParseDirWithExt(dir string, allowedExtensions []string) (map[string]string, error)

ParseDirWithExt returns a new instance of all CSS files located within the provided directory.

func WalkDir

func WalkDir(dir string, callback DirWalker) error

WalkDir will run through the provided path which is expected to be a directory and runs the provided callback with the current path and FileInfo.

Types

type DirStatement

type DirStatement struct {
	Total      int
	DirRoot    string
	FilesByExt map[string][]FileStatement
}

DirStatement defines a structure for all files retrieved from the giving directory.

func GetDirStatement

func GetDirStatement(dir string, doGo bool) (DirStatement, error)

GetDirStatement returns a instance of a DirStatement which contains all files retrieved through running the directory.

type DirWalker

type DirWalker func(rel string, abs string, info os.FileInfo) bool

DirWalker defines a function type which for processing a path and it's info retrieved from the fs.

type FileStatement

type FileStatement struct {
	Path    string `json:"path"`
	AbsPath string `json:"abspath"`
}

FileStatement defines a structure to contain the details of a given file.

type Packer

type Packer interface {
	Pack(files []FileStatement, dir DirStatement) ([]WriteDirective, error)
}

Packer exposes a interface which exposes methods for validating the type of files it supports and a method to appropriately pack the FileStatments as desired into the given endpoint directory.

type StaticDirective

type StaticDirective struct {
	WriteInFile bool
	FileName    string
	DirName     string
}

StaticDirective defines a specific directive option which requires the content of the file be written into it's own single file as dictated by the DirName and FileName provided.

type Webpack

type Webpack struct {
	// contains filtered or unexported fields
}

Webpack defines the core structure for handling bundling of different assets using registered packers.

func New

func New(defaultPacker Packer) *Webpack

New returns a new instance of the Webpack.

func (*Webpack) Build

func (w *Webpack) Build(dir string, doGoSources bool) (map[string][]WriteDirective, map[string][]WriteDirective, error)

Build runs through the directory pull all files and runs them through the packers to service each files by extension and returns a slice of all WriteDirective for final processing.

func (*Webpack) Compile

func (w *Webpack) Compile(dir string, doGoSources bool) (io.WriterTo, map[string][]WriteDirective, error)

Compile returns a io.WriterTo which contains a complete source of all assets generated and stored inside a io.WriteTo which will contain the go source excluding the package declaration so has to allow you write the contents into the package you wish.

func (*Webpack) Register

func (w *Webpack) Register(ext string, packer Packer)

Register adds the Packer to manage the building of giving exensions.

type WriteDirective

type WriteDirective struct {
	OriginPath    string
	OriginAbsPath string
	Writer        io.WriterTo
	Static        *StaticDirective
}

WriteDirective defines a type which defines a directive with details of the content to be written to and the original path and abspath of it's origin.

func (WriteDirective) Read

func (directive WriteDirective) Read() (string, error)

Read will copy directives writer into a content buffer and returns the giving string representation of that data, content will be gzipped.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL