Autostyle
This is a simple gem to make it easier to handle styles for HTML elements.
It treats the styles as a hash, allowing styles to be merged easily.
It responds to to_s, producing CSS output
Installation
Add this line to your application's Gemfile:
gem 'autostyle'
And then execute:
$ bundle
Or install it yourself as:
$ gem install autostyle
Usage
style = Autostyle[background: { color: :red }]
style.merge!(background: { color: :blue })
style[:background].merge!(color: :blue)
style[:text][:size] = '14px'
puts "style=\"#{style}\""
style.merge!(background: 'no-repeat')
puts style.to_s
style[:background] = '#ffffff'
puts style.to_s
style[:background] = { color: :red }
puts style.to_s
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/automeow/autostyle.
License
The gem is available as open source under the terms of the MIT License.