-
Notifications
You must be signed in to change notification settings - Fork 357
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
JS API: Support custom functions #10
Comments
Are there any chances that we will get more intuitive and clear API for working with custom functions? Current way of custom functions declaration in Working with colors gave us especial headaches, since in many places we had declaration of hexadecimal colors in plain string, like Besides, it would be great to have way to pass in variables too, not only functions. Ideally, something like: functions:
'my-func': (arg1, arg2) =>
return arg1 + arg2
'myVar': someJsVar instead of functions:
'my-func($arg1, $arg2)': (arg1, arg2) =>
return castToSass(arg1) + castToSass(arg2)
# 'myVar': someJsVar
# no way to do this |
For the time being, Dart Sass's focus is on matching the existing API so that we can be compatible with existing codebases that are written to Node Sass. Once that's complete, we may start working with node-sass to improve the APIs, but it's not a near-term goal. |
Quite an old thread, I hope you don't mind me posting here. I created a package, jSass (https://github.com/body-builder/jsass), which helps exactly in what @ArmorDarks asked. Example:
It converts the Sass arguments to JS types and converts the returning JS values to Sass types. It also supports JS variable injection to Sass (and also vice versa). The simpler syntax, suggested by @ArmorDarks
or even
is also a great idea. It doesn't look to be too difficult to implement. I will do this in case there will be interest about the package. @nex3 @ArmorDarks Please have a look at jSass and please also spread the word, if you find the package useful. disclaimer: I am the author of the module, but please don't take it as spam. I do hope that Sass end-users can benefit with the use of jSass. TBH, it was only @ArmorDarks 's comment, where I learned about the existence of @chriseppstein 's useful |
We need to support the node-sass API's
functions
option, which specifies custom functions that can be called from Sass stylesheets. This will involve exposing SassScript objects, and making them API-compatible with node-sass.The text was updated successfully, but these errors were encountered: