<%= content = parameters.default ajax_attrs, attributes = attributes.partition_hash(HoboRapidHelper::AJAX_ATTRS) unless ajax_attrs.blank? add_data_rapid!(attributes, "a", :ajax_attrs => ajax_attrs) end if query_params if query_params==true || query_params.blank? query_params = query_parameters_filtered else query_params = query_parameters_filtered(:only => comma_split(query_params)) end params = query_params.merge(params || HashWithIndifferentAccess.new) end if href || attributes[:name] # Regular link href += "?" + params.map { |n, v| "#{n}=#{v}" }.join('&') if !params.blank? element(:a, attributes.update(:href => href), content) else url_options, attributes = attributes.partition_hash(%w(only_path protocol host subdomain domain tld_length port anchor trailing_slash)) url_options[:subsite] = subsite params = url_options.merge(params || {}) target = to || this if target.nil? Dryml.last_if = false nil_view elsif action == "new" # Link to a new object form new_record = target.respond_to?(:build) ? target.build : target.new new_record.set_creator(current_user) href = object_url(target, "new", params) if href && (force || can_create?(new_record)) new_class_name = if target.respond_to?(:proxy_association) target.proxy_association.reflection.klass.name else target.name end add_classes!(attributes, "new-#{new_class_name.underscore}-link") content = "New #{new_class_name.titleize}" if content.blank? Dryml.last_if = true element(:a, attributes.update(:href => href), content) else Dryml.last_if = false "" end else # Link to an existing object content = name if content.blank? href = object_url(target, action, params) unless (action.nil? && target.try.new_record?) if href.nil? # This target is registered with Hobo::Routes as not linkable content else css_class = target.try.origin_attribute || target.class.name.underscore.dasherize add_classes!(attributes, "#{css_class}-link") href.sub!(/\?|$/, ".#{format}\\0") unless format.blank? # Set default link text if none given element(:a, attributes.update(:href => href), content) end end end %>