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
Deprecated.
Don’t use the name of the object anymore, use ‘renderer.object` instead.
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.
146
147
148
149
|
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 146
def method_missing(method, *params, &block)
return @_local_object if @_local_object_name.to_s == method.to_s
super
end
|
Instance Method Details
#assign(key, value = nil) { ... } ⇒ Object
Set global renderer assigns. These are accessible throughout all render/render_collection calls. They are especially usefull in scenarios where you want a sub-item render a piece of the page. You can assign it to ‘:content_for_sidebar` and in your page template you can read `assigns(:content_for_sidebar)` and place the content the content item rendered to the variable `:content_for_sidebar`
18
19
20
21
22
23
24
25
|
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 18
def assign(key, value = nil, &block)
return @_template_assigns[key] if value.nil? && !block_given?
if block_given?
@_template_assigns[key] = capture(&block)
else
@_template_assigns[key] = value
end
end
|
#controller ⇒ Object
96
97
98
|
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 96
def controller
@_controller
end
|
#cookies ⇒ Object
80
81
82
|
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 80
def cookies
@_controller.cookies
end
|
#flash ⇒ Object
91
92
93
|
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 91
def flash
@_controller.send(:flash)
end
|
138
139
140
|
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 138
def form_authenticity_token
@_controller.send(:form_authenticity_token)
end
|
#params ⇒ Object
75
76
77
|
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 75
def params
@_controller.params
end
|
#peek(n = 1, &block) ⇒ Object
45
46
47
|
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 45
def peek(n=1, &block)
renderer.peek(n, &block)
end
|
#peek_until(&block) ⇒ Object
50
51
52
|
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 50
def peek_until(&block)
renderer.peek_until(&block)
end
|
#protect_against_forgery? ⇒ Boolean
128
129
130
|
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 128
def protect_against_forgery?
@_controller.send(:protect_against_forgery?)
end
|
#render_collection(objects, options = {}, &block) ⇒ Object
40
41
42
|
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 40
def render_collection(objects, options = {},&block)
renderer.render_collection(objects, options, &block)
end
|
#render_object(object, options = {}) ⇒ Object
35
36
37
|
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 35
def render_object(object, options = {})
renderer.render(object, options)
end
|
#render_until(&block) ⇒ Object
55
56
57
|
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 55
def render_until(&block)
renderer.render_until(&block)
end
|
Get’s the current Renderer instance that is rendering the template we’re in.
30
31
32
|
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 30
def renderer
@_renderer
end
|
#request ⇒ Object
The request that’s currently being processed
87
88
89
|
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 87
def request
@_controller.request
end
|
#request_forgery_protection_token ⇒ Object
133
134
135
|
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 133
def request_forgery_protection_token
@_controller.request_forgery_protection_token
end
|
#session ⇒ Object
70
71
72
|
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 70
def session
@_controller.session
end
|
#site ⇒ Object
The site that’s currently in scope for this template
103
104
105
|
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 103
def site
@_site
end
|
#skip!(n = 1) ⇒ Object
60
61
62
|
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 60
def skip!(n=1)
renderer.skip!(n)
end
|
#skip_until!(&block) ⇒ Object
65
66
67
|
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 65
def skip_until!(&block)
renderer.skip_until!(&block)
end
|
#url_for(options = {}) ⇒ Object
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
# File 'lib/skyline/rendering/helpers/renderer_helper.rb', line 108
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
|