File: main.go

package info (click to toggle)
golang-github-wellington-go-libsass 0.9.2%2Bgit20181130.4ef5b9d-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,128 kB
  • sloc: cpp: 28,607; ansic: 839; makefile: 44
file content (44 lines) | stat: -rw-r--r-- 930 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Create a preamble for every CSS file
package main

import (
	"bytes"
	"log"
	"os"

	"github.com/wellington/go-libsass"
)

func main() {
	libsass.RegisterHeader(`
/*
 * This is a preamble which will be added to every CSS file generated.
 * It uses the libSass header which includes the text on every file.
 *
 */`)

	// Input Sass source
	input := `div {}`

	buf := bytes.NewBufferString(input)
	// Starts a compiler writing to Stdout and reading from
	// a bytes buffer of the input source
	comp, err := libsass.New(os.Stdout, buf)
	if err != nil {
		log.Fatal(err)
	}

	// Run() kicks off the compiler and instructs libsass how
	// to read our input, handling the output from libsass
	if err := comp.Run(); err != nil {
		log.Fatal(err)
	}

	// Output:
	// /*
	//  * This is a preamble which will be added to every CSS file generated.
	//	* It uses the libSass header which includes the text on every file.
	//	*
	//	*/
	//
}