Module: Skyline::Rendering::Helpers::RendererHelper

Defined in:
lib/skyline/rendering/helpers/renderer_helper.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *params, &block) ⇒ Object

Simple, quick ‘n dirty solution so you can use ’acticle_version’, ‘news_item’, .. in all your templates. So you don’t have to use @.… or pass the local to all partials.



124
125
126
127
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 124

def method_missing(method, *params, &block)
  return @_local_object if @_local_object_name == method
  super
end

Instance Method Details

#assign(key, value = nil) ⇒ Object



5
6
7
8
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 5

def assign(key, value = nil)
  return @_template_assigns[key] if value.nil?
  @_template_assigns[key] = value
end

#cookiesObject

See Also:

  • ActionController::Cookies#cookies


63
64
65
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 63

def cookies
  @_controller.cookies
end

#flashObject



74
75
76
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 74

def flash
  @_controller.send(:flash)
end

#form_authenticity_tokenObject

See Also:

  • ActionController::RequestForgeryProtection#form_authenticity_token


116
117
118
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 116

def form_authenticity_token
  @_controller.send(:form_authenticity_token)
end

#paramsObject

See Also:

  • ActionController::Request#params


58
59
60
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 58

def params
  @_controller.params
end

#peek(n = 1, &block) ⇒ Object



28
29
30
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 28

def peek(n=1, &block)
  renderer.peek(n, &block)
end

#peek_until(&block) ⇒ Object

See Also:

  • Skyline::Renderer#peek_until}


33
34
35
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 33

def peek_until(&block)
  renderer.peek_until(&block)
end

#protect_against_forgery?Boolean

Returns:

  • (Boolean)

See Also:

  • ActionController::RequestForgeryProtection#protect_against_forgery?


106
107
108
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 106

def protect_against_forgery?
  @_controller.send(:protect_against_forgery?)
end

#render_collection(objects, options = {}, &block) ⇒ Object



23
24
25
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 23

def render_collection(objects, options = {},&block)
  renderer.render_collection(objects, options, &block)
end

#render_object(object, options = {}) ⇒ Object



18
19
20
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 18

def render_object(object, options = {})
  renderer.render(object, options)
end

#render_until(&block) ⇒ Object



38
39
40
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 38

def render_until(&block)
  renderer.render_until(&block)
end

#rendererSkyline::Renderer

Get’s the current Renderer instance that is rendering the template we’re in.

Returns:



13
14
15
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 13

def renderer
  @_renderer
end

#requestObject

The request that’s currently being processed

Returns:

  • ActiveRecord::Request



70
71
72
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 70

def request
  @_controller.request
end

#request_forgery_protection_tokenObject

See Also:

  • ActionController::RequestForgeryProtection#request_forgery_protection_token


111
112
113
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 111

def request_forgery_protection_token
  @_controller.request_forgery_protection_token
end

#sessionObject

See Also:

  • ActionController::Request#session


53
54
55
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 53

def session
  @_controller.session
end

#siteObject

The site that’s currently in scope for this template

Returns:

  • Skyline::Site



81
82
83
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 81

def site
  @_site
end

#skip!(n = 1) ⇒ Object



43
44
45
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 43

def skip!(n=1)
  renderer.skip!(n)
end

#skip_until!(&block) ⇒ Object



48
49
50
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 48

def skip_until!(&block)
  renderer.skip_until!(&block)
end

#url_for(options = {}) ⇒ Object

See Also:

  • ActionView::Helpers::UrlHelper#url_for


86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 86

def url_for(options = {})
  options ||= {}
  url = case options
  when String
    super
  when Hash
    options = { :only_path => options[:host].nil? }.update(options.symbolize_keys)
    escape  = options.key?(:escape) ? options.delete(:escape) : true
    @_controller.send(:url_for, options)
  when :back
    escape = false
    @_controller.request.env["HTTP_REFERER"] || 'javascript:history.back()'
  else
    super
  end

  escape ? escape_once(url) : url
end