New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

autostyle

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

autostyle

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

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 }]

# Both of these are equal
style.merge!(background: { color: :blue })
style[:background].merge!(color: :blue)

# Don't need to worry about nil errors
style[:text][:size] = '14px'

puts "style=\"#{style}\"" # implicitly converted to a string when needed
# style="background-color: blue; text-size: 14px"

# Merging a value for a style with "children" works as so:
style.merge!(background: 'no-repeat')
puts style.to_s # background-color: blue; background: no-repeat; text-size: 14px

# Or you can overwrite it:
style[:background] = '#ffffff'
puts style.to_s # text-size: 14px; background: #ffffff

# And with a hash:
style[:background] = { color: :red }
puts style.to_s # text-size: 14px; background-color: red

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.

FAQs

Package last updated on 11 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc