libsass

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2020 License: MIT Imports: 6 Imported by: 10

Documentation

Overview

Package libsass a SCSS transpiler to CSS using LibSASS.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Status  int    `json:"status"`
	Column  int    `json:"column"`
	File    string `json:"file"`
	Line    int    `json:"line"`
	Message string `json:"message"`
}

func (Error) Error

func (e Error) Error() string

type Options

type Options struct {
	// Default is nested.
	OutputStyle OutputStyle

	// Precision of floating point math.
	Precision int

	// File paths to use to resolve imports.
	IncludePaths []string

	// ImportResolver can be used to supply a custom import resolver, both to redirect
	// to another URL or to return the body.
	ImportResolver func(url string, prev string) (newURL string, body string, resolved bool)

	// Used to indicate "old style" SASS for the input stream.
	SassSyntax bool

	// Source map settings
	SourceMapFilename       string
	SourceMapRoot           string
	InputPath               string
	OutputPath              string
	SourceMapContents       bool
	OmitSourceMapURL        bool
	EnableEmbeddedSourceMap bool
}

type OutputStyle

type OutputStyle int
const (
	NestedStyle OutputStyle = iota
	ExpandedStyle
	CompactStyle
	CompressedStyle
)

func (OutputStyle) String

func (i OutputStyle) String() string

type Result

type Result struct {
	CSS string

	// If source maps are configured.
	SourceMapFilename string
	SourceMapContent  string
}

type Transpiler

type Transpiler interface {
	Execute(src string) (Result, error)
}
Example
package main

import (
	"fmt"
	"log"

	"github.com/bep/golibsass/libsass"
)

func main() {
	transpiler, err := libsass.New(libsass.Options{OutputStyle: libsass.CompressedStyle})
	if err != nil {
		log.Fatal(err)
	}

	result, err := transpiler.Execute(`
$font-stack:    Helvetica, sans-serif;
$primary-color: #333;

body {
  font: 100% $font-stack;
  color: $primary-color;
}
`)

	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(result.CSS)
}
Output:

body{font:100% Helvetica,sans-serif;color:#333}

func New

func New(options Options) (Transpiler, error)

New creates a new libsass transpiler configured with the given options.

Jump to

Keyboard shortcuts

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