module MasterView module Directives # creates a collection_select helper. quotes object and method if necessary, merges # html options specfied on element into any html options in attr_value # attr_value syntax: # object, method, collection, value_method, text_method, options = {}, html_options = {} class Collection_select < MasterView::DirectiveBase def stag(dcs) #eat end def etag(dcs) args = parse_attr_value obj = quote_if(args[0]) method = quote_if(args[1]) collection = quote_if(args[2]) value_method = quote_if(args[3]) text_method = quote_if(args[4]) options = args[5] html_options = args[6] opt = {} opt[:size] = attrs_lck['size'].to_i if attrs_lck['size'] opt.merge! common_html_options(attrs_lck) html_options = merge_into_embedded_hash(html_options, 0, opt) options = '{}' if options.to_s.empty? && !html_options.to_s.empty? # if we have html_options but no options, still need empty hash a = [] a << 'collection_select '+ obj a << method a << collection a << value_method a << text_method a << options unless options.to_s.strip.empty? a << html_options unless html_options.to_s.strip.empty? self.content = '' erb_content(a.join(', ')) end end end end