Module: Faalis::Generators::Concerns::Render

Included in:
DashboardScaffold
Defined in:
lib/faalis/generators/concerns/render.rb

Overview

This concern will add render method to generators which load template partials

Instance Method Summary (collapse)

Instance Method Details

- (Object) render(source, &block) (private)



10
11
12
13
14
15
16
17
# File 'lib/faalis/generators/concerns/render.rb', line 10

def render(source, &block)
  source  = File.expand_path(find_in_source_paths("#{source.to_s}.erb"))
  context = instance_eval('binding')

  content = ERB.new(::File.binread(source), nil, '-').result(binding)
  content = block.call(content) if block
  content
end