handlers

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2015 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func FontURL

func FontURL(v interface{}, usv libsass.SassValue, rsv *libsass.SassValue) error

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

func ImageHeight(v interface{}, usv libsass.SassValue, rsv *libsass.SassValue) error

ImageHeight takes a file path (or sprite glob) and returns the height in pixels of the image being referenced.

func ImageURL

func ImageURL(v interface{}, csv libsass.SassValue, rsv *libsass.SassValue) error

ImageURL handles calls to resolve a local image from the built css file path.

func ImageWidth

func ImageWidth(v interface{}, usv libsass.SassValue, rsv *libsass.SassValue) error

ImageWidth takes a file path (or sprite glob) and returns the width in pixels of the image being referenced.

func InlineImage

func InlineImage(v interface{}, usv libsass.SassValue, rsv *libsass.SassValue) error

InlineImage returns a base64 encoded png from the input image

func Sprite

func Sprite(v interface{}, usv libsass.SassValue, rsv *libsass.SassValue) error

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

func SpriteFile(v interface{}, usv libsass.SassValue, rsv *libsass.SassValue) error

SpriteFile proxies the sprite glob and image name through.

func SpriteMap

func SpriteMap(v interface{}, usv libsass.SassValue, rsv *libsass.SassValue) error

SpriteMap returns a sprite from the passed glob and sprite parameters.

func SpritePosition added in v0.9.2

func SpritePosition(v interface{}, usv libsass.SassValue, rsv *libsass.SassValue) error

SpritePosition returns the position of the image in the sprite-map. This is useful for passing directly to background-position

func WarnHandler added in v0.9.2

func WarnHandler(v interface{}, csv libsass.SassValue, rsv *libsass.SassValue) error

WarnHandler captures Sass warnings and redirects to stdout

Types

type Resolver added in v1.0.1

type Resolver interface {
	Do(string) (io.ReadCloser, error)
}

Resolver interface returns a ReadCloser from a path

Jump to

Keyboard shortcuts

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