Module: Innate::Helper::Render
- Defined in:
- lib/innate/helper/render.rb
Class Method Summary collapse
-
.included(into) ⇒ Object
Enables you to simply call:.
Instance Method Summary collapse
- #render_custom(action_name, variables = {}) {|action| ... } ⇒ Object
-
#render_full(path, query = {}) ⇒ Object
Renders the full action in the way a real request would.
-
#render_partial(action_name, variables = {}) ⇒ Object
Renders an action without any layout.
-
#render_view(action_name, variables = {}) ⇒ Object
Renders an action view, doesn’t execute any methods and won’t wrap it into a layout.
Class Method Details
.included(into) ⇒ Object
Enables you to simply call:
9 10 11 |
# File 'lib/innate/helper/render.rb', line 9 def self.included(into) into.extend(self) end |
Instance Method Details
#render_custom(action_name, variables = {}) {|action| ... } ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/innate/helper/render.rb', line 63 def render_custom(action_name, variables = {}) action = resolve(action_name.to_s) action.sync_variables(self.action) action.instance = action.node.new action.variables = action.variables.merge(variables) yield(action) if block_given? if action.valid? action.render else Log.warn("Invalid action: %p" % action) end end |
#render_full(path, query = {}) ⇒ Object
Renders the full action in the way a real request would.
Please be aware that, if this is the first request from a client, you will not have access to the session in the action being rendered, as no actual session has been put into place yet.
It should work as expected on any subsequent requests.
As usual, patches welcome.
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/innate/helper/render.rb', line 26 def render_full(path, query = {}) uri = URI(path.to_s) uri.query = Rack::Utils.build_query(query) if = request.env['HTTP_COOKIE'] Mock.session do |mock| mock. = return mock.get(uri.to_s).body end else Mock.get(uri.to_s).body end end |
#render_partial(action_name, variables = {}) ⇒ Object
Renders an action without any layout.
44 45 46 47 48 |
# File 'lib/innate/helper/render.rb', line 44 def render_partial(action_name, variables = {}) render_custom(action_name, variables) do |action| action.layout = nil end end |
#render_view(action_name, variables = {}) ⇒ Object
Renders an action view, doesn’t execute any methods and won’t wrap it into a layout.
56 57 58 59 60 61 |
# File 'lib/innate/helper/render.rb', line 56 def render_view(action_name, variables = {}) render_custom(action_name, variables) do |action| action.layout = nil action.method = nil end end |