Module: ActionController::PartialHelper
- Defined in:
- lib/vex/action_controller/partial_helper.rb
Instance Method Summary collapse
-
#partial(partial, object = nil, locals = nil) ⇒ Object
partial <partial-name>, <object>, <locals> or partial <object>, <locals>.
- #partial?(*args) ⇒ Boolean
- #partial_for(name) ⇒ Object
- #render_vex_partial(opts) ⇒ Object
Instance Method Details
#partial(partial, object = nil, locals = nil) ⇒ Object
partial <partial-name>, <object>, <locals> or partial <object>, <locals>
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/vex/action_controller/partial_helper.rb', line 14 def partial(partial, object=nil, locals=nil) # # set up object and locals unless partial.is_a?(String) object, locals = partial, object end if !locals && object.is_a?(Hash) locals, object = object, nil end opts = { :partial => partial_for(partial), :locals => locals } if object opts[:object] = object elsif locals && locals[:collection] opts[:collection] = locals[:collection] end # # set up localite?? if defined?(Localite) && !(scope = File.basename(partial).gsub(/\..*/, "")).blank? Localite.scope(scope) do render_vex_partial(opts) end else render_vex_partial(opts) end end |
#partial?(*args) ⇒ Boolean
54 55 56 57 58 59 |
# File 'lib/vex/action_controller/partial_helper.rb', line 54 def partial?(*args) partial *args rescue ActionView::MissingTemplate logger.debug $!.to_s nil end |
#partial_for(name) ⇒ Object
2 3 4 5 6 7 8 |
# File 'lib/vex/action_controller/partial_helper.rb', line 2 def partial_for(name) case name when String then name when Array then partial_for name.first else "sh/#{name.class.name.underscore}" end end |
#render_vex_partial(opts) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/vex/action_controller/partial_helper.rb', line 46 def render_vex_partial(opts) if self.is_a?(ActionController::Base) render_to_string(opts) else render(opts) end end |