Class: Super::Partial

Inherits:
Object
  • Object
show all
Defined in:
lib/super/partial.rb,
lib/super/partial/resolving.rb

Defined Under Namespace

Modules: Resolving

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, locals: {}) ⇒ Partial

Returns a new instance of Partial.



17
18
19
20
# File 'lib/super/partial.rb', line 17

def initialize(path, locals: {})
  @to_partial_path = path
  @locals = locals
end

Instance Attribute Details

#localsObject (readonly)

Returns the value of attribute locals.



23
24
25
# File 'lib/super/partial.rb', line 23

def locals
  @locals
end

#to_partial_pathObject (readonly)

Returns the value of attribute to_partial_path.



22
23
24
# File 'lib/super/partial.rb', line 22

def to_partial_path
  @to_partial_path
end

Class Method Details

.render(partialish, template:) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/super/partial.rb', line 5

def self.render(partialish, template:)
  if partialish.respond_to?(:to_partial_path)
    if partialish.respond_to?(:locals)
      template.render(partialish, partialish.locals)
    else
      template.render(partialish)
    end
  else
    partialish
  end
end