Class: Redmine::Views::OtherFormatsBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/redmine/views/other_formats_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(view) ⇒ OtherFormatsBuilder

Returns a new instance of OtherFormatsBuilder



21
22
23
# File 'lib/redmine/views/other_formats_builder.rb', line 21

def initialize(view)
  @view = view
end

Instance Method Details



25
26
27
28
29
30
# File 'lib/redmine/views/other_formats_builder.rb', line 25

def link_to(name, options={})
  url = { :format => name.to_s.downcase }.merge(options.delete(:url) || {}).except('page')
  caption = options.delete(:caption) || name
  html_options = { :class => name.to_s.downcase, :rel => 'nofollow' }.merge(options)
  @view.('span', @view.link_to(caption, url, html_options))
end

Preserves query parameters



33
34
35
36
37
38
39
40
# File 'lib/redmine/views/other_formats_builder.rb', line 33

def link_to_with_query_parameters(name, url={}, options={})
  params = @view.request.query_parameters.except(:page, :format).except(*url.keys)
  url = {:params => params, :page => nil, :format => name.to_s.downcase}.merge(url)

  caption = options.delete(:caption) || name
  html_options = { :class => name.to_s.downcase, :rel => 'nofollow' }.merge(options)
  @view.('span', @view.link_to(caption, url, html_options))
end