You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the new experimental functions feature of libSass, I can write a Sass function in JavaScript. But I'm running into problems trying to access global Sass variables.
It is common for Sass module developers to specify the default values of their mixin or function parameters as equaling a global variables value. e.g.
Error: Undefined variable: "$my-module-global".
on line 1 of [c function]
>> hi($name: $my_module_global)
----------^
Now, if you say its not possible to use a global variable in the string that contains the function and parameters names ('hi($name: $my_module_global)'), I'm cool with that.
However, I would still need to access Sass global variables from within the main body of my function. Like this:
var sass = require('node-sass');
sass.render({
data: '$my_module_global: "World"; .test { content: hi(); }',
functions: {
'hi($name: "nocanhazglobalhere")': function(name, done) {
// How do I access global Sass variables like $my_module_global in here?
done(sass.types.String('Hello, ' + name.getValue() + '!'));
}
}
}, function(error, result) {
console.log(result ? result.css.toString() : error);
});
Copying this issue from the node-sass queue, sass/node-sass#1297.
Using the new experimental functions feature of libSass, I can write a Sass function in JavaScript. But I'm running into problems trying to access global Sass variables.
It is common for Sass module developers to specify the default values of their mixin or function parameters as equaling a global variables value. e.g.
But I get an error when I try to specify a global variable in the function definition in JS-land. Specifically, doing this:
gives me this error:
Now, if you say its not possible to use a global variable in the string that contains the function and parameters names (
'hi($name: $my_module_global)'
), I'm cool with that.However, I would still need to access Sass global variables from within the main body of my function. Like this:
I'm not sure if this is a missing part of the API in libSass. I looked at https://github.com/sass/libsass/blob/master/docs/api-function.md but there are parts of it I don't understand.
The text was updated successfully, but these errors were encountered: