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.19.8 app/helpers/coco/tag_helper.rb
coveragebook_components-0.19.7 app/helpers/coco/tag_helper.rb
coveragebook_components-0.19.6 app/helpers/coco/tag_helper.rb
coveragebook_components-0.19.5 app/helpers/coco/tag_helper.rb
coveragebook_components-0.19.4 app/helpers/coco/tag_helper.rb
coveragebook_components-0.19.3 app/helpers/coco/tag_helper.rb
coveragebook_components-0.19.2 app/helpers/coco/tag_helper.rb
coveragebook_components-0.19.1 app/helpers/coco/tag_helper.rb
coveragebook_components-0.19.0 app/helpers/coco/tag_helper.rb
coveragebook_components-0.18.8 app/helpers/coco/tag_helper.rb
coveragebook_components-0.18.7 app/helpers/coco/tag_helper.rb
coveragebook_components-0.18.0 app/helpers/coco/tag_helper.rb
coveragebook_components-0.17.7 app/helpers/coco/tag_helper.rb
coveragebook_components-0.17.6 app/helpers/coco/tag_helper.rb
coveragebook_components-0.17.5 app/helpers/coco/tag_helper.rb
coveragebook_components-0.17.4 app/helpers/coco/tag_helper.rb
coveragebook_components-0.17.3 app/helpers/coco/tag_helper.rb
coveragebook_components-0.17.2 app/helpers/coco/tag_helper.rb
coveragebook_components-0.17.1 app/helpers/coco/tag_helper.rb
coveragebook_components-0.17.0 app/helpers/coco/tag_helper.rb