Class: Mako::HTMLRenderer

Inherits:
Object
  • Object
show all
Includes:
FileOpenUtil
Defined in:
lib/mako/html_renderer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FileOpenUtil

included, #load_resource

Constructor Details

#initialize(args) ⇒ HTMLRenderer

Returns a new instance of HTMLRenderer.



9
10
11
12
13
# File 'lib/mako/html_renderer.rb', line 9

def initialize(args)
  @template = args.fetch(:template, File.expand_path(File.join('themes', "#{Mako.config.theme}.html.erb"), Dir.pwd))
  @bound = args.fetch(:bound)
  @feed_template = File.expand_path('layouts/_feed_container.html.erb', __dir__)
end

Instance Attribute Details

#boundObject (readonly)

Returns the value of attribute bound.



7
8
9
# File 'lib/mako/html_renderer.rb', line 7

def bound
  @bound
end

#feed_templateObject (readonly)

Returns the value of attribute feed_template.



7
8
9
# File 'lib/mako/html_renderer.rb', line 7

def feed_template
  @feed_template
end

#templateObject (readonly)

Returns the value of attribute template.



7
8
9
# File 'lib/mako/html_renderer.rb', line 7

def template
  @template
end

Instance Method Details

#file_pathString

Default file name for rendererd file.

Returns:

  • (String)


26
27
28
# File 'lib/mako/html_renderer.rb', line 26

def file_path
  'index.html'
end

#renderString

Wrapper for ERB renderer. Creates new ERB instance with view template and renders it with binding from core.

Returns:

  • (String)


19
20
21
# File 'lib/mako/html_renderer.rb', line 19

def render
  ERB.new(load_resource(template)).result(bound.get_binding)
end