Module: ActionController::PartialHelper

Defined in:
lib/vex/action_controller/partial_helper.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.disable_localiteObject



2
3
4
# File 'lib/vex/action_controller/partial_helper.rb', line 2

def self.disable_localite
  @no_localite = true
end

.localite?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/vex/action_controller/partial_helper.rb', line 6

def self.localite?
  defined?(Localite) && !@no_localite
end

Instance Method Details

#partial(partial, object = nil, locals = nil) ⇒ Object

partial <partial-name>, <object>, <locals> or partial <object>, <locals>



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 22

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
  
  render_vex_partial(opts)
end

#partial?(*args) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
49
50
51
# File 'lib/vex/action_controller/partial_helper.rb', line 46

def partial?(*args)
  partial *args
rescue ActionView::MissingTemplate
  logger.debug $!.to_s
  nil
end

#partial_for(name) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/vex/action_controller/partial_helper.rb', line 10

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