Here is a Compass Extension providing you all functions you need to manipulate your Sass lists. See complete documentation here.
gem install SassyLists
- Add
require 'SassyLists'
to yourconfig.rb
- Import it in your stylesheets with
@import 'SassyLists'
chunk()
: returns whether list contains $valuecontain()
: returns whether the list contains the valuecount-values()
: counts the number of occurrences of each value of listdebug()
: returns list as a stringfirst()
: returns first item in listflatten()
: turns multidimensional list into a one-level listinsert-nth()
: inserts value at indexintersection()
: returns a list of shared values across all given listsis-symmetrical()
: checks if list is symmetricallast()
: returns last item in listlast-index()
: returns last index of value in listloop()
: shifts indexes in listprepend()
: prepends value to listpurge()
: removes allfalse
andnull
values from listrandom-value()
: returns random value from listremove()
: removes value in listremove-duplicates()
: removes duplicate values from listremove-nth()
: removes value at indexreplace()
: replaces value in listreplace-nth()
: replaces value at indexreverse()
: reverses listslice()
: slices listsort()
: sorts listsum()
: sums all unitless values in listto-string()
: casts list as string (JS.join()
)union()
: returns a list of values from given lists minus duplicates
If you feel like an explorer, you can have a look at the code here.
- Sass ~> 3.2.0
- Compass ~> 0.12.2 (obviously)
Some functions depend on other functions. If you include functions individually, make sure to check for these dependencies in their respective docs.
- Official site
- Advanced Sass list functions
- Advanced Sass list functions again
- How I made a Sass debug function
A million thanks to Vinay Raghu for making this Compass extension out of my original work and to Team-Sass for their Compass Extension template.