Re: [Sass] Reading defined variables from functions, or calling functions without using return value

24 views
Skip to first unread message

Chris Eppstein

unread,
Apr 24, 2013, 5:44:19 PM4/24/13
to sass...@googlegroups.com
The way to accomplish this is with variable defaults. In the file that defines the generate-custom-background() function you would define the config variable yourself with the !default flag:

$some-config-var: red !default;

Then you can use it in your functions. If the downstream stylesheet sets this either before or after the import, it will still be blue because the value of red is only assigned when the variable is not already set.

-Chris


On Sun, Apr 21, 2013 at 11:10 PM, Gabriel Gilder <gabriel...@gmail.com> wrote:
Hi all,

I'm trying to figure out a good way to allow custom configuration of a Sass plugin I'm building. The two options that spring to mind are reading special variables defined in the SASS stylesheet, or providing custom functions for configuration. But both have problems.

For example, in a user's stylesheet:

$some-config-var: blue
.someclass
  background: generate-custom-background()

Assuming "generate-custom-background" is a custom function, is there a way for it to determine that the stylesheet defines the variable "$some-config-var"? It seems like Compass does something like this for sprites, but I haven't had much luck puzzling through the source to figure out how.

As an alternate approach, is there any way to allow a custom function to not output anything? I'd like to have something like:

configure-custom-var(blue)

But that attempts to parse whatever value is returned as CSS.

Any help would be appreciated!

Thanks,
-Gabriel

--
You received this message because you are subscribed to the Google Groups "Sass" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sass-lang+...@googlegroups.com.
To post to this group, send email to sass...@googlegroups.com.
Visit this group at http://groups.google.com/group/sass-lang?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages