Skip to content
This repository has been archived by the owner on Jun 26, 2018. It is now read-only.

Fixes and custom function support #7

Merged
merged 22 commits into from
Sep 22, 2014
Merged

Fixes and custom function support #7

merged 22 commits into from
Sep 22, 2014

Conversation

leafo
Copy link
Contributor

@leafo leafo commented Dec 20, 2013

Hello,

I'm making this pull request just to make you aware of these changes. You can pick and choose what you want and I can re-submit. I did a couple things. The ffi bindings were out of date so I updated them to work with latest version of libsass. I didn't notice the other pull request #5 also did this until I wrote my code. It looks like we did approximately the same thing.

I added custom function support. This depends on this patch for libsass: sass/libsass#181. I did this by exposing all the Sass_Value types and writing code to convert between them and ruby. It would be nice to merge that patch into libsass. (I have my own version that only adds custom function support with no other changes so if that's preferred I can submit that as a pull request)

The custom function interface is pretty basic, it mimics the libsass api instead of the ruby sass one but all the groundwork is there to make it match ruby sass's api.

It looks like this:

engine = SassC::Engine.new(".hello { color: hello(one, two, three); }")

engine.custom_function "hello($arg1, $arg2, $arg3)" do |arg_list|
    arg_list.join("-")
end

You can see more examples of the type conversion in the specs: https://github.com/hcatlin/sassruby/pull/7/files#diff-72f0204d5517b4f250f5e2cdf312dac0R120

I wrote specs for all code I added and specs for basic execution which were missing.

Lastly, I noticed some .bundle variant of libsass was hardcoded into the SassC::Lib. I renamed the referenced library to just sass which means that it should load the library installed in the system (of any platform). I'm not too familiar with what is preferred for native extensions, the extconf stuff didn't work anyway when installing the gem because it didn't know how to check out the submodule.

Lastly I made it run on ruby 1.8 becuase that's what we currently use. Just a few minor changes.

sassruby speeds up asset compilation for our deploys by minutes so I'd love to see this code be available for more developers.

Thanks

@mikelewis
Copy link

+1

1 similar comment
@conanbatt
Copy link

+1

@AlJohri
Copy link

AlJohri commented Mar 30, 2014

+1

@mgreter
Copy link

mgreter commented Jun 6, 2014

The fixes for the C sass_interface have landed: https://github.com/hcatlin/libsass/releases/tag/v2.0. Maybe also check sass/node-sass#332 for a small overview of the newly available features.

@HamptonMakes HamptonMakes merged commit 14344af into sass:master Sep 22, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants