How can I test if a Sass function exists?
I have a Sass package that uses a custom Sass function. However, outside Ruby (e.g. libsass), that function may not be defined and a fallback is provided:
url: if($bootstrap-sass-asset-helper, twbs-font-path('name.eot'), 'name.eot')
I would like to set the value of $bootstrap-sass-asset-helper
to true or false depending on whether twbs-font-path
is declared.
The current version of Sass has a function-exists
function. Full example:
.foo {
@if function-exists(myfunc) {
exists: true;
}
@else {
exists: false;
}
}
This is new functionality to v3.3 (March 2014), so you may need to update your Sass gem to utilize it.
Sass v3.3 adds other existence tests too:
variable-exists($name)
global-variable-exists($name)
mixin-exists($name)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments