Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple example of using go-libsass to compile SCSS to CSS #32

Open
drewwells opened this issue Dec 3, 2015 · 10 comments
Open

Simple example of using go-libsass to compile SCSS to CSS #32

drewwells opened this issue Dec 3, 2015 · 10 comments

Comments

@drewwells
Copy link
Member

Should include simple examples of how to use go-libsass in custom projects

@drewwells
Copy link
Member Author

@tboerger I saw your post on c6. If you're interested in compiling scss to css maybe check out go-libsass.

To compile scss to css with go-libsass

package main

import (
    "bytes"
    "log"
    "os"

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

func main() {
    buf := bytes.NewBufferString(`div { p { color: red; } }`)
    comp, _ := libsass.New(os.Stdout, buf)
    err := comp.Run()
    if err != nil {
        log.Fatal(err)
    }
}

There are many options for altering the compiler behavior listed here: https://github.com/wellington/go-libsass/blob/master/compiler.go#L56-L192

@drewwells
Copy link
Member Author

@jpillora you seemed to have a similar desire to compile scss. This example of go-libsass may be helpful for you

@tboerger
Copy link

tboerger commented Dec 3, 2015

go-libsass is a nice library, but I really like the principle of c6 to be a pure go implementation :)

@drewwells
Copy link
Member Author

Sure, it's a nice idea but sass is not a simple language to implement. Which is why c6 has stalled for so long. On the other side, there's a very good implementation in C to start from. Not to say it can't be implemented in Go eventually!

@tboerger
Copy link

tboerger commented Dec 3, 2015

I know that it's not simple... I'm using and following sass already for years :).

Maybe I can integrate go-libsass into Gogs.

@drewwells
Copy link
Member Author

Watching libsass integrate every nook and cranny of Sass is a challenge. Though with the years of maintaining a go wrapper to the c library, I probably could have written a decent Sass parser by now.

I'm a fan of the attempts to implement partial language Sass (Sass the good parts?). Sadly, these seemed to have been abandoned and it's unlikely they'll support most of the common Sass frameworks due to corner cases in Sass.

Speaking of, there's a project in this repo with a working Scss/Sass lexer. I started off this project by working on a Sass lexer before fully switching to libsass https://github.com/wellington/sass/. If you're interested in working on a Sass parser, I could use help there. There's a yacc based parser, but the ambiguities in the language will prevent it from doing much. Bison's generalized grammar might get somewhere, but I think invariably Sass will require a parser built by hand.

@drewwells
Copy link
Member Author

Feel free to reach out if you need help with gogs integration. There's also a cli tool which has examples of how to use go-libsass and adds additional functionality to Sass (like spriting).

@tboerger
Copy link

tboerger commented Dec 4, 2015

Sounds great, we will see how I can do it :)

@drewwells
Copy link
Member Author

@tboerger I've begun work on a Pure Go compiler, it's nowhere near completion but can handle simple Sass compilation: https://github.com/wellington/sass

@tboerger
Copy link

tboerger commented Nov 2, 2016

@tboerger I've begun work on a Pure Go compiler, it's nowhere near completion but can handle simple Sass compilation: https://github.com/wellington/sass

That's really interesting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants