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

Allow optional params #7

Merged
merged 7 commits into from
Jun 24, 2015
Merged

Conversation

edward
Copy link
Member

@edward edward commented Jun 22, 2015

Adds support for:

  • Optional parameters in custom Sass functions
  • Better exception handling for custom Sass functions

Bonus:

  • Refactored Rakefile-related stuff for packaging/testing

@nickjs @bolandrm for review


value = functs.send(custom_function, s)
custom_function_arguments << argument
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to add an else here that raises something like NotImplemented for now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For values that aren’t a :sass_string? Yeah, that’s a good idea.

I also kinda want to just implement the rest 😄

It looks like the type classes like SassC:Script:String look just like their Sass versions, but with an added #to_native and a couple other tweaks.

How would you feel about temporarily requiring the Sass counterparts like https://github.com/sass/sass/blob/stable/lib/sass/script/value/string.rb and inheriting + extending/overriding those classes? Then we wouldn’t fall behind as Sass grows / our copy-pasted version stays static.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's unfortunate to have the sass dependency long term, but right at the moment, sassc-rails requires sass too (because sprockets requires sass). I suppose that would be a good solution for the present.

I can't exactly remember, but i think I may have had to tweak the String value class (i.e. it might not be exactly the same as it is in sass).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Purely for informational purposes, and not to add an opinion or bias one way or the other, we did a diff. The only things that you seem to have changed are:

  • removed a super call from the constructor
  • added self.type and self.unquote class methods
  • added #to_native
  • removed #plus, #to_sass, and #inspect. Or maybe those just didn't exist yet?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from that, both keeping sass as a dependency and copy/pasting the Sass::Script counterparts feel equally dirty to me :(

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to add an else here that raises something like NotImplemented for now?

@bolandrm Since hooking into libsass’ own error handling stuff is a little too tricky for me at the moment, I’ve added some code that upon error, spits out a Sass syntax error and also logs to $stderr.

@bolandrm
Copy link
Member

Looking good to me. thanks for the rakefile refactors.

# ADDAPI char* ADDCALL sass_error_get_message (const union Sass_Value* v);
# ADDAPI void ADDCALL sass_error_set_message (union Sass_Value* v, char* msg);
attach_function :sass_error_get_message, [:sass_value_ptr], :string
attach_function :sass_error_set_message, [:sass_value_ptr, :pointer], :void
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤘

@edward edward force-pushed the allow-optional-params branch from b43b733 to 5806d11 Compare June 22, 2015 22:23
@edward edward force-pushed the allow-optional-params branch from 5806d11 to 4b4d324 Compare June 23, 2015 15:39
@edward
Copy link
Member Author

edward commented Jun 23, 2015

@bolandrm we cool to merge on green?

bolandrm added a commit that referenced this pull request Jun 24, 2015
@bolandrm bolandrm merged commit 50b9abb into sass:master Jun 24, 2015
michael-gillett pushed a commit to michael-gillett/sassc-ruby that referenced this pull request Apr 25, 2019
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

Successfully merging this pull request may close these issues.

3 participants