Here is a Compass Extension providing you all functions you need to manipulate your Sass lists. See complete documentation here.
Current version: 0.2.1.
gem install SassyLists- Add
require 'SassyLists'to yourconfig.rb - Import it in your stylesheets with
@import 'SassyLists'
chunk(): chunks list into size large listscount-values(): counts the number of occurrences of each value of listdebug(): returns list as a stringfirst(): returns first item in listinsert-nth(): inserts value at indexis-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 allfalseandnullvalues 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())
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.