Class: Primrose::Prim

Inherits:
Object
  • Object
show all
Defined in:
lib/primrose/prim.rb

Class Method Summary collapse

Class Method Details

.render(template, context) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/primrose/prim.rb', line 9

def self.render(template, context)
  # template = read_template(template_path)
  erb = ERB.new(template)
  rendered = erb.result(context.get_binding)

  # replace partial tags with actual content
  rendered.gsub(/<%= partial "(.*?)" %>/) do
    partial_path = File.join('templates/partials', "#{$1}.prim.erb")
    render(partial_path, context)
  end
end