diff options
Diffstat (limited to 'railties/lib/vendor/thor/lib/thor/actions/template.rb')
m--------- | railties/lib/vendor/thor | 0 | ||||
-rw-r--r-- | railties/lib/vendor/thor/lib/thor/actions/template.rb | 38 |
2 files changed, 38 insertions, 0 deletions
diff --git a/railties/lib/vendor/thor b/railties/lib/vendor/thor deleted file mode 160000 -Subproject fccc2fddfb3e696d4715bfddc1c25211fc7480d diff --git a/railties/lib/vendor/thor/lib/thor/actions/template.rb b/railties/lib/vendor/thor/lib/thor/actions/template.rb new file mode 100644 index 0000000000..6b2e50b8c5 --- /dev/null +++ b/railties/lib/vendor/thor/lib/thor/actions/template.rb @@ -0,0 +1,38 @@ +require 'thor/actions/templater' +require 'erb' + +class Thor + module Actions + + # Gets an ERB template at the relative source, executes it and makes a copy + # at the relative destination. If the destination is not given it's assumed + # to be equal to the source removing .tt from the filename. + # + # ==== Parameters + # source<String>:: the relative path to the source root + # destination<String>:: the relative path to the destination root + # log_status<Boolean>:: if false, does not log the status. True by default. + # + # ==== Examples + # + # template "README", "doc/README" + # + # template "doc/README" + # + def template(source, destination=nil, log_status=true) + destination ||= source.gsub(/.tt$/, '') + action Template.new(self, source, destination, log_status) + end + + class Template < Templater #:nodoc: + + def render + @render ||= begin + context = base.instance_eval('binding') + ERB.new(::File.read(source), nil, '-').result(context) + end + end + + end + end +end |