Sha256: 14550266aec7b8b9d8d57f4e44db6e2d73663066196beffea492300285307d3a

Contents?: true

Size: 495 Bytes

Versions: 73

Compression:

Stored size: 495 Bytes

Contents

module Coco
  module TagHelper
    def prefix_attr_keys(attrs, prefix)
      attrs.transform_keys! { [prefix, _1].map(&:to_s).join("-") }
    end

    # Converts an hash to an string of CSS styles for use in HTML `style` attributes
    def style_str(styles)
      styles.to_h.compact.reduce([]) do |array, (key, value)|
        array << "#{key.to_s.dasherize}: #{value}"
      end.join("; ")
    end

    def random_id(length = 6)
      ("a".."z").to_a.shuffle[0, length].join
    end
  end
end

Version data entries

73 entries across 73 versions & 1 rubygems

Version Path
coveragebook_components-0.6.4 app/helpers/coco/tag_helper.rb
coveragebook_components-0.6.3 app/helpers/coco/tag_helper.rb
coveragebook_components-0.6.2 app/helpers/coco/tag_helper.rb
coveragebook_components-0.6.1 app/helpers/coco/tag_helper.rb
coveragebook_components-0.6.0 app/helpers/coco/tag_helper.rb
coveragebook_components-0.5.7 app/helpers/coco/tag_helper.rb
coveragebook_components-0.5.6 app/helpers/coco/tag_helper.rb
coveragebook_components-0.5.5 app/helpers/coco/tag_helper.rb
coveragebook_components-0.5.4 app/helpers/coco/tag_helper.rb
coveragebook_components-0.5.3 app/helpers/coco/tag_helper.rb
coveragebook_components-0.5.2 app/helpers/coco/tag_helper.rb
coveragebook_components-0.5.1 app/helpers/coco/tag_helper.rb
coveragebook_components-0.5.0 app/helpers/coco/tag_helper.rb