20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/capistrano/configuration/resources/file_resources.rb', line 20
def template(name, options={})
path = options.fetch(:path, "." )
if File.exist?(File.join(path, "#{name}.erb"))
name = "#{name}.erb"
else
types = MIME::Types.type_for(name)
if types.include?("text/html")
name_without_ext = File.basename(name, File.extname(name))
if File.exist?(File.join(path, "#{name_without_ext}.rhtml"))
name = "#{name_without_ext}.rhtml"
end
end
end
begin
ERB.new(file(name, options)).result(options.fetch(:binding, binding))
rescue StandardError => error
abort("Could not render template resource - #{error}")
end
end
|