Sha256: 535800593daa48f72ef0e14f3a8aababaa0e20e1366e72b2751543148828c48c

Contents?: true

Size: 1014 Bytes

Versions: 3

Compression:

Stored size: 1014 Bytes

Contents

module AuxiliaryAddons
  module HtmlHelper
    # ::Rails.logger.error("...")
  
    #
    # Common HTML helpers
    #
  
    #
    def hash_to_string(params = {})
      result = ""
      params.each do |key, value|
        blank = result.blank?
        result += (key.to_s + "=" + value.to_s) if blank
        result += ("&" + key.to_s + "=" + value.to_s) if !blank
      end
  
      # TODO: replace whitespaced and etc
      result
    end
  
    #
    def newlines_to_htmlbrs(str)
      return str if (str.nil? || str.blank?)
      str.gsub!(/\n/, '</br>')
    end
  
    #
    def erase_spaces(str)
      return str if (str.nil? || str.blank?)
      str.gsub!(/\s/, '')
    end
  
    #
    def unique_id(key)
      @unique_ids = Hash.new() if @unique_ids.nil?
      @unique_ids[key] = 0 if @unique_ids[key].nil?
      @unique_ids[key] += 1
      last_id(key)
    end
  
    # 
    def last_id(key)
      key + "." + @unique_ids[key].to_s
    end
  
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
auxiliary_addons-0.5.6 lib/auxiliary_addons/html_helper.rb
auxiliary_addons-0.5.5 lib/auxiliary_addons/html_helper.rb
auxiliary_addons-0.5.4 lib/auxiliary_addons/html_helper.rb