Sha256: 8791073aa06e260818d5eae39ff72c5a1198f2d06ac53e5761593a5fe2bf6ad2
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
module WorldFlagsHelper def self.flag_sizes [16, 32, 64] end def flags_list size = 16, &block raise "Missing block" unless block_given? raise "Supported sizes are only #{WorldFlagsHelper.flag_sizes}" unless WorldFlagsHelper.flag_sizes.include?(size.to_i) content = capture(&block) content_tag :ul, content, :class => "f#{size}" end alias_method :flag_list, :flags_list def flags flags_hash, display = false flags_hash.inject("") do |res, element| res << flag(element.first, element.last, display) end.html_safe end def flags_title flags_hash flags_hash.inject("") do |res, element| res << flag_title(element.first, element.last) end.html_safe end def flag code, name, display = false label = display ? name : ' ' content_tag :li, label.html_safe, :class => "flag #{code}", :'data-country' => name, :'data-cc' => code end def flag_title code, name, display = false label = display ? name : ' ' content_tag :li, label.html_safe, :class => "flag #{code}", :title => name, :'data-cc' => code end def use_flags size = 16 stylesheet_link_tag "flags/flags#{size}" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
world-flags-0.1.3 | lib/world_flags/world_flags_helper.rb |