Sha256: 7386a888ef85bc03085b167410e13809cb4ba97ba04597f78ed6ed06280bd80d
Contents?: true
Size: 1.53 KB
Versions: 18
Compression:
Stored size: 1.53 KB
Contents
require 'world_flags/helper/view/util' module WorldFlags module Helper module View def self.flag_sizes [16, 32, 64] end def flags_list size = 16, &block raise "Missing block" unless block_given? unless WorldFlags::Helper::View.flag_sizes.include?(size.to_i) raise "Supported sizes are only #{WorldFlags::Helper::View.flag_sizes}" end content = capture(&block) content_tag :ul, content, :class => "f#{size}" end alias_method :flag_list, :flags_list # http://en.wikipedia.org/wiki/ISO_639-1_language_matrix # should look up translation for each code def flags *args options = args.extract_options! args.flatten! args.inject("") do |res, elem| case elem when String, Symbol code = elem name = WorldFlags.label(code, options) else raise ArgumentError, "Bad argument: #{args}, must be Array" end res << flag(code, name, options) end.html_safe end def flags_title *args options = args.extract_options! flags args, options.merge(:title => true) end def flag code, name, options = {} label = WorldFlags::Helper::View::Util.label_for options title = WorldFlags::Helper::View::Util.title_for name, options content_tag :li, label.html_safe, WorldFlags::Helper::View::Util.flag_options(code, title, name, options) end def flag_title code, name, options = {} flag code, name, options.merge(:title => true) end def use_flags size = 16 stylesheet_link_tag "flags/flags#{size}" end end end end
Version data entries
18 entries across 18 versions & 1 rubygems