summaryrefslogtreecommitdiff
path: root/lib/web/view_engine.rb
blob: 398b7460a63fcae50079aeac28e1baad8e1a39e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
module Booty
  class ViewEngine
    def initialize(root_path: 'lib/commands', master: 'master', template_expander: TemplateExpansion.new(root_path))
      @root_path = root_path
      @master = "#{master}.html.erb"
      @template_expander = template_expander
    end

    def render(template: '', model: OpenStruct.new )
      dto = OpenStruct.new(:model => model)
      dto.content = @template_expander.expand("#{template}.html.erb", dto)
      @template_expander.expand(@master, dto)
    end
  end
end