Method: Thor::Actions#template2

Defined in:
lib/rag/ext.rb

#template2(source, *args, &block) ⇒ Object

use tilt :scope => nil :locals => {} &block is for yield.



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rag/ext.rb', line 13

def template2(source, *args, &block)
  config = args.last.is_a?(Hash) ? args.pop : {}
  destination = args.first || source.sub(/\.tt$/, '')
  template_options = {source_root: self.class.source_root}

  source = File.expand_path(find_in_source_paths(source.to_s))

  create_file destination, nil, config do
    Rag::Template.render(source, template_options, &block)
  end
end