Module: Awestruct::Extensions::Partial

Defined in:
lib/awestruct/extensions/partial.rb

Instance Method Summary collapse

Instance Method Details

#partial(path, params = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/awestruct/extensions/partial.rb', line 5

def partial(path, params = {})
  filename = File.join( '_partials', path )

  if !File.exists?( filename )
    return nil
  end

  page = site.engine.load_site_page( filename )

  return nil if !page

  params.each do |k,v|
    page.send( "#{k}=", v )
  end if params

  page.content
end