3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/dimples/writeable.rb', line 3
def write(path, context = {})
output = context ? render(context) : contents
parent_path = File.dirname(path)
begin
FileUtils.mkdir_p(parent_path) unless Dir.exist?(parent_path)
File.open(path, 'w+') do |file|
file.write(output)
end
rescue SystemCallError => e
error_message = "Failed to write #{path}"
error_message << " (#{e.message})" if @site.config['verbose_logging']
raise Errors::PublishingError.new(error_message)
end
end
|