Documentation ¶
Index ¶
- func FontURL(v interface{}, usv libsass.SassValue, rsv *libsass.SassValue) error
- func ImageHeight(v interface{}, usv libsass.SassValue, rsv *libsass.SassValue) error
- func ImageURL(v interface{}, csv libsass.SassValue, rsv *libsass.SassValue) error
- func ImageWidth(v interface{}, usv libsass.SassValue, rsv *libsass.SassValue) error
- func InlineImage(v interface{}, usv libsass.SassValue, rsv *libsass.SassValue) error
- func Sprite(v interface{}, usv libsass.SassValue, rsv *libsass.SassValue) error
- func SpriteFile(v interface{}, usv libsass.SassValue, rsv *libsass.SassValue) error
- func SpriteMap(v interface{}, usv libsass.SassValue, rsv *libsass.SassValue) error
- func SpritePosition(v interface{}, usv libsass.SassValue, rsv *libsass.SassValue) error
- func WarnHandler(v interface{}, csv libsass.SassValue, rsv *libsass.SassValue) error
- type Resolver
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FontURL ¶
FontURL builds a relative path to the requested font file from the built CSS.
Example ¶
in := bytes.NewBufferString(` $path: font-url($raw: true, $path: "arial.eot"); @font-face { src: font-url("arial.eot"); src: url("#{$path}"); }`) _, _, err := setupCtx(in, os.Stdout) if err != nil { fmt.Println(err) }
Output: @font-face { src: url("../font/arial.eot"); src: url("../font/arial.eot"); }
func ImageHeight ¶
ImageHeight takes a file path (or sprite glob) and returns the height in pixels of the image being referenced.
func ImageWidth ¶
ImageWidth takes a file path (or sprite glob) and returns the width in pixels of the image being referenced.
func InlineImage ¶
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"); }`) ctx := libsass.NewContext() initCtx(ctx) ctx.BuildDir = "../test/build" ctx.GenImgDir = "../test/build/img" ctx.ImageDir = "../test/img" var out bytes.Buffer err := ctx.Compile(in, &out) if err != nil { fmt.Println(err) } io.Copy(os.Stdout, &out)
Output: div { background: url("img/4f0c6e.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 ); }`) ctx := libsass.NewContext() initCtx(ctx) ctx.BuildDir = "../test/build" ctx.GenImgDir = "../test/build/img" ctx.ImageDir = "../test/img" var out bytes.Buffer err := ctx.Compile(in, &out) if err != nil { fmt.Println(err) } io.Copy(os.Stdout, &out)
Output: div { background-position: 0px, -149px; } div.retina { background-position: 10px -74px; }
func SpriteFile ¶
SpriteFile proxies the sprite glob and image name through.
func SpritePosition ¶ added in v0.9.2
SpritePosition returns the position of the image in the sprite-map. This is useful for passing directly to background-position
Types ¶
Click to show internal directories.
Click to hide internal directories.