Sassy eases the pain for object-oriented programmers and makes getting around in SASS a little easier.
Changes: All methods and mixins will now start with
sassy-
, with aliasing optional.
Sassy provides some essential functionality and makes working with maps much easier.
It also includes a debugging utility for unit-testing (see notes at the bottom).
Note: 'methods and uses' must be expanded to jump to a specific function
Mapping Tools | Essentials | Extras | Administrative | Other |
---|---|---|---|---|
get | compare | explode | thru | types |
set | type | implode | types-same | |
has | contains | increase | apply | - |
- | - | decrease | - | - |
All methods that use a ( map, key, ... ) signature allow for nested maps using a key list!
( list, of, keys )
View Sassy methods and uses.
gets an value from a map key. for nested maps, use a list of keys
Signatures and Supported Types
Signature:
- get( map, key )
- get( map, ( nested, key ) )
Supported types: map
sets a key:value pair in a map. for nested maps, use a key list
Signatures and Supported Types
Signature:
- set( map, key, value )
- set( map, ( nested, key ), value )
@note Remember SASS objects are immutable. Replace your map reference each time!
Supported types: map
checks if a map has a key. optionally returns the value
Signatures and Supported Types
Signature: has( map, key, [return], [default] )
Optional default value IF NO KEY (otherwise returns null).
Supported types: map
compares 2 things
gets the type of an object (optional check string to compare and return bool)
returns the types of all args provided in a new list
checks that all vars provided are the same type
checks if one thing contains another
Signatures and Supported Types
Signature: contains( haystack, needle )
Supported types: map, list, string
breaks a string by {delimiter}, returns as list
Signatures and Supported Types
Signature: explode( string, [delimiter='-'] )
Supported types: string
joins list items between glue, returning as a string
Signatures and Supported Types
Signature: implode( list, [wrap=false], [glue=', '] )
@note wrap is optional. if true, adds ( ) to string before returning
Supported types: list
returns the first argument straight thru (useful for testing purposes)
prints a map as a string representation (similar to native "inspect" function)
essentially 'calls' a function. values will be fed as call unless they are a list or map. if list, passed as multiple args. if you need to pass a single list, use an "argsmap" ( args: ( your, list ) ) as the arguments param. used by debugger
Signatures and Supported Types
Signature:
- apply( method_name, argslist... )
- apply( method_name, ( list, of, args ) )
- apply( method_name, argsmap )
Supported types: function
increases a number [in a map] by X
Signatures and Supported Types
Signature:
- increase( number, [x=1] )
- increase( map, key, [x=1] )
Supported types: number, map with number as value to a key
decreases a number [in a map] by X
Signatures and Supported Types
Signature:
- decrease( number, [x=1] )
- decrease( map, key, [x=1] )
Supported types: number, map with number as value to a key
pulls a shared key from multiple maps
Signatures and Supported Types
Signature: pluck( key, maps.. )
@note also accepts a list of maps
Supported types: map
I put together a SASS debug utility based loosely on my much more robust JS debugger.
There are only 3 mixins you need (really only "test", but it's better to use all 3).
View Sassy debug mixins
Mixin: start
starts a debugger
Signature: @include start(debug_name)
Mixin: test
performs a unit test and echos result
Signatures and Uses
Signature:
- @include test( method_name, arguments, [expect=true] )
- @include test( name, result, [expect=true] )
You should always use a list of arguments instead of a result boolean.
The result boolean option is there for edge cases where comparing the result isn't so easy.
If you need to pass a single list, use an argsmap
( args: ( your, list ) )
You can add a variation string as the 4th parameter. Useful if debugging similar signatures.
Mixin: complete
reports a summary of pass | fail.
Signature: @include complete;
Include this after your last test. It will tell you that all tests passed or which ones failed (and why).
That's all! Enjoy the software!