lib/world_flags/helper/view.rb in world-flags-0.5.1 vs lib/world_flags/helper/view.rb in world-flags-0.6.0

- old
+ new

@@ -5,17 +5,18 @@ module View def self.flag_sizes [16, 24, 32, 48, 64] end - def flags_list size = 24, &block + def flags_list size = 24, options = {}, &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}" + xclass = options[:class] ? " #{options[:class]}" : '' + content_tag WorldFlags.flag_list_tag, content, :class => "f#{size} flags#{xclass}" end alias_method :flag_list, :flags_list # http://en.wikipedia.org/wiki/ISO_639-1_language_matrix @@ -38,17 +39,23 @@ def flags_title *args options = args.extract_options! flags args, options.merge(:title => true) end - def flag code, name, options = {} + def flag code, *args + options = args.extract_options! + name = args.first.kind_of?(String) ? args.first : WorldFlags.label(code, 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) + content_tag WorldFlags.flag_tag, label.html_safe, WorldFlags::Helper::View::Util.flag_options(code, title, name, options) end - def flag_title code, name, options = {} + def flag_title code, *args + options = args.extract_options! + name = args.first.kind_of?(String) ? args.first : WorldFlags.label(code, options) + flag code, name, options.merge(:title => true) end def use_flags size = 24 stylesheet_link_tag "flags/flags#{size}" \ No newline at end of file