libs

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2018 License: Apache-2.0 Imports: 12 Imported by: 21

Documentation

Overview

libs is a direct mapping to libsass C API. This package should not be necessary to do any high level operations. It is instead intended that go-libsass handles everything needed in your project.

In case where low level API calls are necessary, use this package to do so. For more details on what these methods do see: https://github.com/sass/libsass/wiki/API-Documentation

For the most part, consider this a hand curated SWIG of libsass C API.

Index

Constants

This section is empty.

Variables

View Source
var SassUnitConversions map[string]map[string]float64 = sassUnitConversions

Functions

func BindFuncs

func BindFuncs(opts SassOptions, cookies []Cookie) []int

BindFuncs attaches a slice of Functions to a sass options. Signatures are already defined in the SassFunc.

func BindHeader

func BindHeader(opts SassOptions, entries []ImportEntry) int

BindHeader attaches the header to a libsass context ensuring gc does not delete the pointers necessary to make this happen.

func BindImporter

func BindImporter(opts SassOptions, entries []ImportEntry) int

BindImporter attaches a custom importer Go function to an import in Sass

func Bool

func Bool(usv UnionSassValue) bool

func Color

func Color(usv UnionSassValue) color.Color

func DeleteValue

func DeleteValue(usv UnionSassValue)

func Float

func Float(usv UnionSassValue) float64

func GetEntry

func GetEntry(es []ImportEntry, parent string, path string) (string, error)

func GetImportList

func GetImportList(ctx SassContext) []string

func HeaderBridge

func HeaderBridge(cint C.int) C.Sass_Import_List

func ImporterBridge

func ImporterBridge(url *C.char, prev *C.char, cidx C.int) C.Sass_Import_List

ImporterBridge is called by C to pass Importer arguments into Go land. A Sass_Import is returned for libsass to resolve.

func Interface

func Interface(usv UnionSassValue) interface{}

Interface creates Go types from union sass_value

func IsBool

func IsBool(usv UnionSassValue) bool

func IsColor

func IsColor(usv UnionSassValue) bool

func IsError

func IsError(usv UnionSassValue) bool

func IsList

func IsList(usv UnionSassValue) bool

func IsMap

func IsMap(usv UnionSassValue) bool

func IsNil

func IsNil(usv UnionSassValue) bool

func IsNumber

func IsNumber(usv UnionSassValue) bool

func IsString

func IsString(usv UnionSassValue) bool

func Len

func Len(usv UnionSassValue) int

func RemoveFuncs

func RemoveFuncs(ids []int) error

func RemoveHeaders

func RemoveHeaders(idx int) error

func RemoveImporter

func RemoveImporter(idx int) error

func SassCompileFileContext

func SassCompileFileContext(gofc SassFileContext) int

SassCompileFileContext compile from file context

func SassCompilerExecute

func SassCompilerExecute(c SassCompiler)

SassCompilerExecute compiles a compiler

func SassCompilerParse

func SassCompilerParse(c SassCompiler)

SassCompilerParse prepares a compiler for execution

func SassContextGetErrorJSON

func SassContextGetErrorJSON(goctx SassContext) string

SassContextGetErrorJSON requests an error in JSON format from libsass

func SassContextGetErrorStatus

func SassContextGetErrorStatus(goctx SassContext) int

SassContextGetErrorStatus requests error status

func SassContextGetOutputString

func SassContextGetOutputString(goctx SassContext) string

SassContextGetOutputString retrieves the final compiled CSS after compiler parses and executes.

func SassContextGetSourceMapString

func SassContextGetSourceMapString(goctx SassContext) string

SassContextGetSourceMapString retrieves the contents of a source map

func SassDataContextSetOptions

func SassDataContextSetOptions(godc SassDataContext, goopts SassOptions)

SassDataContextGetOptions sets a Sass options to a data context

func SassDeleteCompiler

func SassDeleteCompiler(c SassCompiler)

SassDeleteCompiler frees memory for the Sass compiler

func SassDeleteDataContext

func SassDeleteDataContext(dc SassDataContext)

SassDeleteDataContext frees the memory used for a data context

func SassDeleteFileContext

func SassDeleteFileContext(fc SassFileContext)

SassDeleteFileContext frees memory used for a file context

func SassFileContextSetOptions

func SassFileContextSetOptions(gofc SassFileContext, goopts SassOptions)

SassFileContextGetOptions sets a sass options to a file context

func SassImporterGetListEntry

func SassImporterGetListEntry()

func SassImporterSetListEntry

func SassImporterSetListEntry(golst SassImporterList, idx int, ent SassImporter)

SassImporterSetListEntry updates an import list with a new entry. The index must exist in the importer list.

func SassOptionGetSourceMapFile

func SassOptionGetSourceMapFile(goopts SassOptions) string

SassOptionGetSourceMapFile retrieves the source map file

func SassOptionSetCFunctions

func SassOptionSetCFunctions()

func SassOptionSetCHeaders

func SassOptionSetCHeaders(gofc SassOptions, goimp SassImporterList)

SassOptionSetCHeaders adds custom C headers to a SassOptions

func SassOptionSetCImporters

func SassOptionSetCImporters(goopts SassOptions, golst SassImporterList)

func SassOptionSetIncludePath

func SassOptionSetIncludePath(goopts SassOptions, path string)

SassOptionSetIncludePaths adds additional paths to look for input Sass

func SassOptionSetOmitSourceMapURL

func SassOptionSetOmitSourceMapURL(goopts SassOptions, b bool)

func SassOptionSetOutputPath

func SassOptionSetOutputPath(goopts SassOptions, path string)

SassOptionSetOutputPath is used for output path. Output path is used for source map generating. LibSass will not write to this file, it is just used to create information in source-maps etc.

func SassOptionSetOutputStyle

func SassOptionSetOutputStyle(goopts SassOptions, i int)

SassOptionSetOutputStyle sets the output format of CSS see: http://godoc.org/github.com/wellington/go-libsass#pkg-constants

func SassOptionSetPrecision

func SassOptionSetPrecision(goopts SassOptions, i int)

SassOptionSetPrecision sets the precision of floating point math ie. 3.2222px. This is currently bugged and does not work.

func SassOptionSetSourceComments

func SassOptionSetSourceComments(goopts SassOptions, b bool)

SassOptionSetSourceComments toggles the output of line comments in CSS

func SassOptionSetSourceMapContents

func SassOptionSetSourceMapContents(goopts SassOptions, b bool)

func SassOptionSetSourceMapEmbed

func SassOptionSetSourceMapEmbed(goopts SassOptions, b bool)

func SassOptionSetSourceMapFile

func SassOptionSetSourceMapFile(goopts SassOptions, path string)

func SassOptionSetSourceMapRoot

func SassOptionSetSourceMapRoot(goopts SassOptions, path string)

SassOptionSetSourceMapRoot sets the sourceRoot in the resulting source map. sourceRoot is prepended to the sources referenced in the map. More Info: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.75yo6yoyk7x5

func SetIndex

func SetIndex(usv UnionSassValue, i int, item UnionSassValue)

func Slice

func Slice(usv UnionSassValue, inf interface{})

Slice creates a Sass List from a Go slice. Reflection is used.

func String

func String(usv UnionSassValue) string

func ToScss

func ToScss(r io.Reader, w io.Writer) error

ToScss converts Sass to Scss using sass2scss. Readers and Writers are used, but libsass does not support streaming.

func Unit

func Unit(usv UnionSassValue) string

func Version

func Version() string

Types

type Cookie struct {
	Sign string
	Fn   SassCallback
	Ctx  interface{}
}

Cookie is used for passing context information to libsass. Cookie is passed to custom handlers when libsass executes them through the go bridge.

type ImportEntry

type ImportEntry struct {
	Parent string
	Path   string
	Source string
	SrcMap string
}

type SafeMap

type SafeMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

globalImports stores []ImportEntry in a place where GC won't delete it

func (*SafeMap) Del

func (s *SafeMap) Del(idx int)

func (*SafeMap) Get

func (s *SafeMap) Get(idx int) interface{}

func (*SafeMap) Set

func (s *SafeMap) Set(ie interface{}) *int

set accepts an entry and returns an index for it

type SassCallback

type SassCallback func(v interface{}, csv UnionSassValue, rsv *UnionSassValue) error

SassCallback defines the callback libsass eventually executes in sprite_sass

type SassCompiler

type SassCompiler *C.struct_Sass_Compiler

func SassMakeDataCompiler

func SassMakeDataCompiler(godc SassDataContext) SassCompiler

SassMakeDataCompiler returns a compiler from a data context

func SassMakeFileCompiler

func SassMakeFileCompiler(gofc SassFileContext) SassCompiler

SassMakeFileCompiler returns a compiler from a file context

type SassContext

type SassContext *C.struct_Sass_Context

func SassDataContextGetContext

func SassDataContextGetContext(godc SassDataContext) SassContext

SassDataContextGetContext returns a context from a data context. These are useful for calling generic methods like compiling.

func SassFileContextGetContext

func SassFileContextGetContext(gofc SassFileContext) SassContext

SassFileContextGetContext returns a context from a file context. These are useful for calling generic methods like compiling.

type SassDataContext

type SassDataContext *C.struct_Sass_Data_Context

func SassMakeDataContext

func SassMakeDataContext(gos string) SassDataContext

SassMakeDataContext creates a data context from a source string

type SassFileContext

type SassFileContext *C.struct_Sass_File_Context

func SassMakeFileContext

func SassMakeFileContext(gos string) SassFileContext

SassMakeFileContext maps to C.sass_make_file_context

type SassFunc

type SassFunc C.Sass_Function_Entry

func SassMakeFunction

func SassMakeFunction(signature string, idx *int) SassFunc

SassMakeFunction binds a Go pointer to a Sass function signature

type SassImportEntry

type SassImportEntry C.Sass_Import_Entry

func SassMakeImport

func SassMakeImport(path string, base string, source string, srcmap string) SassImportEntry

SassMakeImport creates an import for overriding behavior when certain imports are called.

type SassImportList

type SassImportList C.Sass_Import_List

type SassImporter

type SassImporter *C.struct_Sass_Importer

func SassMakeImporter

func SassMakeImporter(fn SassImporterFN, priority int, v interface{}) (SassImporter, error)

SassMakeImport attaches a Go pointer to a Sass function. Go will eventually kill this behavior and we should find a new way to do this.

type SassImporterFN

type SassImporterFN C.Sass_Importer_Fn

func SassImporterGetFunction

func SassImporterGetFunction(goimp SassImporter) SassImporterFN

type SassImporterList

type SassImporterList C.Sass_Importer_List

func SassMakeImporterList

func SassMakeImporterList(gol int) SassImporterList

SassMakeImporterList maps to C.sass_make_importer_list

type SassNumber

type SassNumber struct {
	Value float64
	Unit  string
}

func Number

func Number(usv UnionSassValue) SassNumber

func (SassNumber) Add

func (sn SassNumber) Add(sn2 SassNumber) SassNumber

Add sums the two numbers in the first numbers units

func (SassNumber) Divide

func (sn SassNumber) Divide(sn2 SassNumber) SassNumber

Divide takes the quotient of the two numbers in the first unit

func (SassNumber) Float

func (n SassNumber) Float() float64

func (SassNumber) Multiply

func (sn SassNumber) Multiply(sn2 SassNumber) SassNumber

Multiply takes the multiplication of the two numbers in the first numbers units

func (SassNumber) String

func (s SassNumber) String() string

func (SassNumber) Subtract

func (sn SassNumber) Subtract(sn2 SassNumber) SassNumber

Subtract minuses the two numbers in the first numbers units

func (SassNumber) UnitOf

func (n SassNumber) UnitOf() string

type SassOptions

type SassOptions *C.struct_Sass_Options

SassOptions is a wrapper to C.struct_Sass_Options

func SassDataContextGetOptions

func SassDataContextGetOptions(godc SassDataContext) SassOptions

SassDataContextGetOptions returns the Sass options in a data context

func SassFileContextGetOptions

func SassFileContextGetOptions(gofc SassFileContext) SassOptions

SassFileContextGetOptions returns the sass options in a file context

func SassMakeOptions

func SassMakeOptions() SassOptions

SassMakeOptions creates a new SassOptions object

type UnionSassValue

type UnionSassValue *C.union_Sass_Value

func CloneValue

func CloneValue(usv UnionSassValue) UnionSassValue

func GoBridge

func GoBridge(cargs UnionSassValue, cidx C.int) UnionSassValue

GoBridge is exported to C for linking libsass to Go. This function adheres to the interface provided by libsass.

func Index

func Index(usv UnionSassValue, i int) UnionSassValue

func MakeBool

func MakeBool(b bool) UnionSassValue

MakeBool creates Sass bool from a bool

func MakeColor

func MakeColor(c color.RGBA) UnionSassValue

MakeColor creates a Sass color from color.RGBA

func MakeError

func MakeError(s string) UnionSassValue

MakeError creates Sass error from a string

func MakeList

func MakeList(len int) UnionSassValue

MakeList creates a Sass List

func MakeMap

func MakeMap(len int) UnionSassValue

MakeMap cretes a new Sass Map

func MakeNil

func MakeNil() UnionSassValue

MakeNil creates Sass nil

func MakeNumber

func MakeNumber(f float64, unit string) UnionSassValue

TODO: validate unit

func MakeString

func MakeString(s string) UnionSassValue

func MakeWarning

func MakeWarning(s string) UnionSassValue

MakeWarning creates Sass warning from a string

func MapKeys

func MapKeys(m UnionSassValue) []UnionSassValue

func NewUnionSassValue

func NewUnionSassValue() UnionSassValue

NewUnionSassValue creates a new empty UnionSassValue

Jump to

Keyboard shortcuts

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