Module: Facades::SassExtensions::Functions
- Defined in:
- lib/facades/sass_extensions/functions.rb
Instance Method Summary collapse
-
#compact(*args) ⇒ Object
Compact via compass Compacts a sass list removing any nil or empty items.
-
#input_types(*args) ⇒ Object
Creates a selector including all fields of a particular type.
-
#prepend(*args) ⇒ Object
Takes a value or values and prepends them to an existing list.
Instance Method Details
#compact(*args) ⇒ Object
Compact via compass Compacts a sass list removing any nil or empty items.
13 14 15 16 17 18 19 20 21 |
# File 'lib/facades/sass_extensions/functions.rb', line 13 def compact(*args) sep = :comma if args.size == 1 && args.first.is_a?(Sass::Script::List) list = args.first args = list.value sep = list.separator end Sass::Script::List.new(args.reject{|a| !a.to_bool}, sep) end |
#input_types(*args) ⇒ Object
Creates a selector including all fields of a particular type. Helpful to target text-like inputs etc.
29 30 31 32 33 |
# File 'lib/facades/sass_extensions/functions.rb', line 29 def input_types(*args) Sass::Script::String.new(args.collect do |type| send(:"#{type}_input_types") end.flatten.compact.join(", ")) end |
#prepend(*args) ⇒ Object
Takes a value or values and prepends them to an existing list.
38 39 40 41 42 43 44 45 46 |
# File 'lib/facades/sass_extensions/functions.rb', line 38 def prepend(*args) existing = args.first unless args.first.is_a?(Sass::Script::List) raise Sass::SyntaxError, "The first argument to 'unshift' must be a list" end existing = existing.value args.each{ |arg| existing.unshift(arg) } Sass::Script::List.new(args, :comma) end |