Documentation
¶
Index ¶
- Constants
- Variables
- func FileHandler(gen string) http.Handler
- func HTTPHandler(ctx *context.Context) func(w http.ResponseWriter, r *http.Request)
- func Init(handle io.Writer)
- func IsSass(r io.Reader) bool
- func LoadAndBuild(sassFile string, gba *BuildArgs, partialMap *SafePartialMap) error
- func ToScssReader(r io.Reader) (io.ReadCloser, error)
- type BuildArgs
- type Parser
- type Replace
- type Response
- type SafePartialMap
- type Watcher
Constants ¶
const MaxTopLevel int = 20
Sets the default size of the slice holding the top level files for a sass partial in SafePartialMap.M
Variables ¶
var ( // Debug future ability to toggle the logging level and destination. Debug *log.Logger )
Functions ¶
func FileHandler ¶ added in v0.7.0
FileHandler starts a file server serving files out of the specified build directory.
func HTTPHandler ¶ added in v0.7.0
HTTPHandler starts a CORS enabled web server that takes as input Sass and outputs CSS.
func IsSass ¶ added in v0.7.0
IsSass determines if the given reader is Sass (not Scss). This is predicted by the presence of semicolons
func LoadAndBuild ¶
func LoadAndBuild(sassFile string, gba *BuildArgs, partialMap *SafePartialMap) error
LoadAndBuild kicks off parser and compiling TODO: make this function testable
func ToScssReader ¶ added in v0.7.0
func ToScssReader(r io.Reader) (io.ReadCloser, error)
ToScssReader ...
Types ¶
type BuildArgs ¶
type BuildArgs struct {
Imgs, Sprites spritewell.SafeImageMap
Dir string
BuildDir string
Includes string
Font string
Gen string
Style int
Comments bool
}
BuildArgs holds universal arguments for a build that the parser uses during the initial build and the filewatcher passes back to the parser on any file changes.
func NewBuildArgs ¶ added in v0.7.0
func NewBuildArgs() *BuildArgs
NewBuildArgs creates a BuildArgs and initializes Cache maps for sprites and images
type Parser ¶
type Parser struct { Idx int Chop []Replace Pwd, Input, MainFile string SassDir, BuildDir, ProjDir string ImageDir string Includes []string Items []lexer.Item Output []byte Line map[int]string LineKeys []int PartialMap *SafePartialMap // contains filtered or unexported fields }
Parser represents a parser engine that returns parsed and imported code from the input useful for doing text manipulation before passing to libsass.
func StartParser ¶
func StartParser(ctx *context.Context, in io.Reader, out io.Writer, partialMap *SafePartialMap) (*Parser, error)
StartParser accepts build arguments TODO: Remove pkgdir, can be referenced from context TODO: Should this be called StartParser or NewParser? TODO: Should this function create the partialMap or is this the right way to inject one?
func (*Parser) GetItems ¶
GetItems recursively resolves all imports. It lexes the input adding the tokens to the Parser object. TODO: Convert this to byte slice in/out
func (*Parser) ImportPath ¶
ImportPath accepts a directory and file path to find partials for importing. Returns the new pwd, string of the file contents, and error. File can contain a directory and should be evaluated if successfully found. Dir is used to provide relative context to the importee. If no file is found pwd is echoed back.
Paths are looked up in the following order: {includepath}/_file.scss {includePath}/_file.sass {includepath}/file.scss {includePath}/file.sass {Dir{dir+file}}/_{Base{file}}.scss {Dir{dir+file}}/_{Base{file}}.sass {Dir{dir+file}}/{Base{file}}.scss {Dir{dir+file}}/{Base{file}}.sass
func (*Parser) LookupFile ¶
LookupFile translates line positions into line number and file it belongs to
type Response ¶ added in v0.7.0
type Response struct { Contents string `json:"contents"` Start time.Time `json:"start"` Elapsed string `json:"elapsed"` Error string `json:"error"` }
Response is the object returned on HTTP responses from wellington
type SafePartialMap ¶
SafePartialMap is a thread safe map of partial sass files to top level files. The file watcher will detect changes in a partial and kick off builds for all top level files that contain that partial.
func NewPartialMap ¶
func NewPartialMap() *SafePartialMap
NewPartialMap creates a initialized SafeParitalMap with with capacity 100
func (*SafePartialMap) AddRelation ¶
func (p *SafePartialMap) AddRelation(mainfile string, subfile string)
AddRelation links a partial Sass file with the top level file by adding a thread safe entry into partialMap.M.
type Watcher ¶
type Watcher struct { FileWatcher *fsnotify.Watcher PartialMap *SafePartialMap Dirs []string BArgs *BuildArgs }
Watcher holds all data needed to kick off a build of the css when a file changes. FileWatcher is the object that triggers builds when a file changes. PartialMap contains a mapping of partials to top level files. Dirs contains all directories that have top level files. GlobalBuildArgs contains build args that apply to all sass files.
Directories
¶
Path | Synopsis |
---|---|
The lexer processes text flagging any sass extended commands sprite* as commands
|
The lexer processes text flagging any sass extended commands sprite* as commands |
Package token defines constants representing the lexical tokens of the Go programming language and basic operations on tokens (printing, predicates).
|
Package token defines constants representing the lexical tokens of the Go programming language and basic operations on tokens (printing, predicates). |
Main package wraps sprite_sass tool for use with the command line See -h for list of available options
|
Main package wraps sprite_sass tool for use with the command line See -h for list of available options |