Module: Filander::Template

Includes:
Base
Included in:
Filander
Defined in:
lib/filander/actions/template.rb

Instance Method Summary collapse

Methods included from Base

#create_directory_for, #entries, #join_destination, #join_source, #report, #with_report

Instance Method Details

#template(source, destination = source) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/filander/actions/template.rb', line 7

def template(source, destination = source)
  create_directory_for destination
  context = instance_eval('binding')
  content = ERB.new(File.read(join_source(source)), nil, '-').result(context)

  with_report destination, content do
    File.open(join_destination(destination), "w") { |file| file << content }
  end
end