Test whether a Sass function is defined

glebm

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.

KatieK

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)

More on Sass v3.3.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Test whether a Sass function is defined

From Dev

Checking whether a function is defined

From Dev

Checking whether a function is defined

From Dev

Uncaught ReferenceError: test (function) is not defined

From Dev

How to test whether an identifier that is accessible only through a #define macro is defined?

From Dev

How to test whether string contains multiple defined words in order?

From Dev

How to test whether string contains multiple defined words in order?

From Dev

How to test whether an identifier that is accessible only through a #define macro is defined?

From Dev

How to test with hspec whether the readerError function was executed

From Dev

User Defined Function to determine whether string contains a substring

From Dev

Test whether a function is called inside another function in unit testing

From Dev

Object.prototype function to test if it is defined / not null?

From Dev

test whether default argument is used or is modified in function call in R

From Dev

Excel function to test whether string contains ANY of $THESE CHARACTERS

From Dev

How can you test a Sass function without using the dom?

From Dev

How do I test whether a text node intervenes between the current node and a defined preceding sibling?

From Dev

Test a function defined in application.js and called in jQuery(function($){} with jasmine

From Dev

ReferenceError: sass is not defined

From Dev

Robot Framework : How to know whether a test library function is being executed from setup/test/teardown

From Dev

using rewire to test node ES6 module - function not defined

From Dev

Test whether globbing is enabled

From Dev

How do you test within a javascript function object whether an invalid method was called?

From Dev

How to apply a function can test whether an element in a list in data frame with python-pandas?

From Dev

Test whether a value is a string in Coldfusion

From Dev

Test whether a property name exists

From Dev

Test whether fortran is installed on OSX

From Dev

Deciding whether a test is a Unit or Integration test

From Dev

How to know whether a racket variable is defined or not

From Dev

Finding whether environment variable is defined or not in C#

Related Related

  1. 1

    Test whether a Sass function is defined

  2. 2

    Checking whether a function is defined

  3. 3

    Checking whether a function is defined

  4. 4

    Uncaught ReferenceError: test (function) is not defined

  5. 5

    How to test whether an identifier that is accessible only through a #define macro is defined?

  6. 6

    How to test whether string contains multiple defined words in order?

  7. 7

    How to test whether string contains multiple defined words in order?

  8. 8

    How to test whether an identifier that is accessible only through a #define macro is defined?

  9. 9

    How to test with hspec whether the readerError function was executed

  10. 10

    User Defined Function to determine whether string contains a substring

  11. 11

    Test whether a function is called inside another function in unit testing

  12. 12

    Object.prototype function to test if it is defined / not null?

  13. 13

    test whether default argument is used or is modified in function call in R

  14. 14

    Excel function to test whether string contains ANY of $THESE CHARACTERS

  15. 15

    How can you test a Sass function without using the dom?

  16. 16

    How do I test whether a text node intervenes between the current node and a defined preceding sibling?

  17. 17

    Test a function defined in application.js and called in jQuery(function($){} with jasmine

  18. 18

    ReferenceError: sass is not defined

  19. 19

    Robot Framework : How to know whether a test library function is being executed from setup/test/teardown

  20. 20

    using rewire to test node ES6 module - function not defined

  21. 21

    Test whether globbing is enabled

  22. 22

    How do you test within a javascript function object whether an invalid method was called?

  23. 23

    How to apply a function can test whether an element in a list in data frame with python-pandas?

  24. 24

    Test whether a value is a string in Coldfusion

  25. 25

    Test whether a property name exists

  26. 26

    Test whether fortran is installed on OSX

  27. 27

    Deciding whether a test is a Unit or Integration test

  28. 28

    How to know whether a racket variable is defined or not

  29. 29

    Finding whether environment variable is defined or not in C#

HotTag

Archive