Class: Onebox::Layout

Inherits:
Mustache
  • Object
show all
Includes:
TemplateSupport
Defined in:
lib/onebox/layout.rb

Constant Summary collapse

VERSION =
"1.0.0"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from TemplateSupport

#load_paths, #template?

Constructor Details

#initialize(name, record) ⇒ Layout

Returns a new instance of Layout.



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/onebox/layout.rb', line 14

def initialize(name, record)
  @record = Onebox::Helpers.symbolize_keys(record)

  # Fix any relative paths
  if @record[:image] && @record[:image] =~ /^\/[^\/]/
    @record[:image] = "#{uri.scheme}://#{uri.host}/#{@record[:image]}"
  end

  @md5 = Digest::MD5.new
  @view = View.new(name, @record)
  @template_name = "_layout"
  @template_path = load_paths.last
end

Instance Attribute Details

#recordObject (readonly)

Returns the value of attribute record.



11
12
13
# File 'lib/onebox/layout.rb', line 11

def record
  @record
end

#viewObject (readonly)

Returns the value of attribute view.



12
13
14
# File 'lib/onebox/layout.rb', line 12

def view
  @view
end

Instance Method Details

#to_htmlObject



28
29
30
# File 'lib/onebox/layout.rb', line 28

def to_html
  render(details)
end