Module: Dimples::Writeable
Instance Method Summary collapse
Instance Method Details
#write(path, context = {}) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/dimples/writeable.rb', line 3 def write(path, context = {}) output = context ? render(context) : contents() publish_path = output_file_path(path) parent_path = File.dirname(publish_path) begin FileUtils.mkdir_p(parent_path) unless Dir.exist?(parent_path) File.open(publish_path, 'w+') do |file| file.write(output) end rescue SystemCallError => e raise Errors::PublishingError.new(publish_path, e.) end end |