Documentation
¶
Index ¶
- Variables
- func FontURL(ctx context.Context, usv libsass.SassValue) (*libsass.SassValue, error)
- func ImageHeight(mainctx context.Context, usv libsass.SassValue) (*libsass.SassValue, error)
- func ImageURL(ctx context.Context, csv libsass.SassValue) (*libsass.SassValue, error)
- func ImageWidth(mainctx context.Context, usv libsass.SassValue) (rsv *libsass.SassValue, err error)
- func InlineImage(mainctx context.Context, usv libsass.SassValue) (rsv *libsass.SassValue, err error)
- func Sprite(ctx context.Context, usv libsass.SassValue) (rsv *libsass.SassValue, err error)
- func SpriteFile(ctx context.Context, usv libsass.SassValue) (rsv *libsass.SassValue, err error)
- func SpriteMap(mainctx context.Context, usv libsass.SassValue) (*libsass.SassValue, error)
- func SpriteNames(ctx context.Context, usv libsass.SassValue) (*libsass.SassValue, error)
- func SpritePosition(mainctx context.Context, usv libsass.SassValue) (rsv *libsass.SassValue, err error)
- func WarnHandler(v interface{}, csv libsass.SassValue, rsv *libsass.SassValue) error
- type Resolver
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrPayloadNil = errors.New("payload is nil")
ErrPayloadNil prevents panics on invalid payload; nil check helps find non-obvious dependency failures like mismatched dependencies.
Functions ¶
func ImageHeight ¶
ImageHeight takes a file path (or sprite glob) and returns the height in pixels of the image being referenced.
func ImageURL ¶
ImageURL handles calls to resolve the path to a local image from the built css file path.
func ImageWidth ¶
ImageWidth takes a file path (or sprite glob) and returns the width in pixels of the image being referenced.
func InlineImage ¶
func InlineImage(mainctx context.Context, usv libsass.SassValue) (rsv *libsass.SassValue, err error)
InlineImage returns a base64 encoded png from the input image
func Sprite ¶
Sprite returns the source and background position for an image in the spritesheet.
Example ¶
in := bytes.NewBufferString(` $map: sprite-map("*.png", 10px); // One argument div { background: sprite($map, "140"); }`) comp, err := libsass.New(os.Stdout, in, libsass.Payload(payload.New()), libsass.ImgDir("../test/img"), libsass.BuildDir("../test/build"), libsass.ImgBuildDir("../test/build/img"), ) if err != nil { log.Fatal(err) } if err := comp.Run(); err != nil { log.Fatal(err) }
Output: div { background: url("img/b9d55f.png") 0px -149px; }
Example (Position) ¶
in := bytes.NewBufferString(` $map: sprite-map("*.png", 10px); // One argument div { background-position: sprite-position($map, "140"); } div.retina { background-position: 10px ceil(nth(sprite-position($map, "140"), 2) /2 ); }`) comp, err := libsass.New(os.Stdout, in, libsass.Payload(payload.New()), libsass.ImgDir("../test/img"), libsass.BuildDir("../test/build"), libsass.ImgBuildDir("../test/build/img"), ) if err != nil { log.Fatal(err) } err = comp.Run() if err != nil { log.Fatal(err) }
Output: div { background-position: 0px, -149px; } div.retina { background-position: 10px -74px; }
func SpriteFile ¶
SpriteFile proxies the sprite glob and image name through.
func SpriteNames ¶ added in v1.0.5
SpriteNames returns the names of all images in a sprite map