Documentation ¶
Overview ¶
Package assets provides asset compilation, concatenation and fingerprinting.
Index ¶
- func ScriptLink(name string) template.HTML
- func StyleLink(name string) template.HTML
- type Collection
- func (c *Collection) Compile(src string, dst string) error
- func (c *Collection) FetchOrCreateGroup(name string) *Group
- func (c *Collection) File(name string) *File
- func (c *Collection) Group(name string) *Group
- func (c *Collection) Load() error
- func (c *Collection) MarshalJSON() ([]byte, error)
- func (c *Collection) Save() error
- func (c *Collection) ScriptLink(names ...string) template.HTML
- func (c *Collection) StyleLink(names ...string) template.HTML
- type File
- type Group
- func (g *Group) AddAsset(p, h string)
- func (g *Group) Compile(dst string) error
- func (g *Group) MarshalJSON() ([]byte, error)
- func (g *Group) ParseFile(p string, dst string) error
- func (g *Group) RemoveFiles(dst string) error
- func (g *Group) ScriptName() string
- func (g *Group) ScriptPath(dst string) string
- func (g *Group) Scripts() []*File
- func (g *Group) String() string
- func (g *Group) StyleName() string
- func (g *Group) StylePath(dst string) string
- func (g *Group) Styles() []*File
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ScriptLink ¶
ScriptLink returns an html tag for a given file path
Types ¶
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
Collection holds the complete list of groups
func (*Collection) Compile ¶
func (c *Collection) Compile(src string, dst string) error
Compile images, styles and scripts asset folders from src into dst (minifying and amalgamating)
func (*Collection) FetchOrCreateGroup ¶
func (c *Collection) FetchOrCreateGroup(name string) *Group
FetchOrCreateGroup returns the named group if it exists, or creates it if not
func (*Collection) File ¶
func (c *Collection) File(name string) *File
File returns the first asset file matching name - this assumes files have unique names between groups
func (*Collection) Group ¶
func (c *Collection) Group(name string) *Group
Group returns the named group if it exists or an empty group if not
func (*Collection) Load ¶
func (c *Collection) Load() error
Load the asset groups from the assets json file Call this on startup from your app to read the asset details after assets are compiled
func (*Collection) MarshalJSON ¶
func (c *Collection) MarshalJSON() ([]byte, error)
MarshalJSON generates json for this collection, of the form {group:{file:hash}}
func (*Collection) Save ¶
func (c *Collection) Save() error
Save the assets to a file after compilation
func (*Collection) ScriptLink ¶
func (c *Collection) ScriptLink(names ...string) template.HTML
ScriptLink converts a set of group names to one script tag (production) or to a list of script tags (development)
type File ¶
type File struct {
// contains filtered or unexported fields
}
File stores a filename and hash fingerprint for the asset file
func (*File) MarshalJSON ¶
MarshalJSON generates json for this file, of the form {group:{file:hash}}
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group holds a name and a list of files (images, scripts, styles)
func (*Group) Compile ¶
Compile compiles all our files and calculates hashes from their contents The group hash is a hash of hashes
func (*Group) MarshalJSON ¶
MarshalJSON generates json for this collection, of the form {group:{file:hash}}
func (*Group) ParseFile ¶
ParseFile adds this asset to our list of files, along with a fingerprint based on the content
func (*Group) RemoveFiles ¶
RemoveFiles removes old compiled files for this group from dst
func (*Group) ScriptName ¶
ScriptName returns a fingerprinted group name for scripts
func (*Group) ScriptPath ¶
ScriptPath returns a fingerprinted group path for scripts