Closed iamajoe closed 8 years ago
https://godoc.org/github.com/wellington/go-libsass#New ?
New accepts anything that returns Option as well like Path https://godoc.org/github.com/wellington/go-libsass#Path
Here's how it is used in the wellington project https://github.com/wellington/wellington/blob/master/build.go#L254-L267
Awesome, thanks for the example :) I'll try to figure it out now.
These optional arguments follow the functional options pattern. There's a good rundown of it works here: http://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis
I just can't figure out the SourceMap. Here is my code:
func (obj cssWriter) Write(p []byte) (n int, err error) {
err = FileRemove(RemoveStruct{Src: obj.Dest})
if err != nil {
return
}
file, err := os.Create(obj.Dest)
file.Write(p)
return
}
comp, err := libsass.New(cssWriter{dest}, data,
libsass.SourceMap(true, cssWriter{dest + ".map"}),
)
Ideas on why?
looks okay, I would check errors on file.Write()
any reason you don't pass a plain os.File?
df, _ := os.Create(dest)
mf, _ := os.Create(dest+".map")
comp, err := libsass.New(df, data,
libsass.SourceMap(true, mf),
)
Noobiness I guess. That is way better than what I have! Regarding the source map, now it creates the file (obviously) but nothing inside
New
function accepts options but I don't know how to pass options to thelibsass
. Is it something supported already?