Class: RERB::Templater

Inherits:
Object
  • Object
show all
Defined in:
lib/rerb/templater.rb

Direct Known Subclasses

IIFETemplater, UMDTemplater

Constant Summary collapse

TEMPLATE =
"<%= content %>"

Instance Method Summary collapse

Constructor Details

#initialize(filename, root_name) ⇒ Templater

Returns a new instance of Templater.



12
13
14
15
# File 'lib/rerb/templater.rb', line 12

def initialize(filename, root_name)
  @viewmodel_name = File.basename(filename, ".*").split("_").map(&:capitalize).join
  @root_name = root_name
end

Instance Method Details

#generate(input) ⇒ Object



17
18
19
20
21
22
# File 'lib/rerb/templater.rb', line 17

def generate(input)
  content = Compiler.new(input, @viewmodel_name, @root_name)
    .compile
  rhtml = ERB.new(self.class::TEMPLATE)
  rhtml.result(binding)
end