lib/spontaneous/output/format.rb in spontaneous-0.2.0.beta4 vs lib/spontaneous/output/format.rb in spontaneous-0.2.0.beta5
- old
+ new
@@ -63,10 +63,14 @@
def to_sym
@name
end
+ def to_s
+ to_sym.to_s
+ end
+
def extension(is_dynamic = false, dynamic_extension = Spontaneous::Output::Template.extension)
if (override = @options[:extension])
return normalise_extension(override.to_s)
end
ext = normalise_extension(name.to_s)
@@ -97,12 +101,12 @@
def postprocess
@options[:postprocess]
end
- def context
- Spontaneous::Site.context (helper_formats + [name]).uniq.compact
+ def context(site = Spontaneous.instance)
+ site.context (helper_formats + [name]).uniq.compact
end
end
extend ClassMethods
extend Forwardable
@@ -119,24 +123,24 @@
def model
content.model
end
- def render(params = {}, *args)
- render_using(default_renderer, params, *args)
+ def render(params = {}, parent_context = nil)
+ render_using(default_renderer, params, parent_context)
end
- def render_using(renderer, params, *args)
+ def render_using(renderer, params = {}, parent_context = nil)
before_render
- output = render_page(renderer, params, *args)
+ output = render_page(renderer, params, parent_context)
output = postprocess(output)
after_render(output)
output
end
def default_renderer
- Spontaneous::Output.renderer
+ Spontaneous::Output.default_renderer
end
def before_render
end
@@ -148,24 +152,16 @@
output = process.call(@page, output)
end
output
end
- def render_page(renderer, params = {}, *args)
- renderer.render(self, params, *args)
+ def render_page(renderer, params = {}, parent_context = nil)
+ renderer.render(self, params, parent_context)
end
- def publish_page(renderer, revision)
+ def publish_page(renderer, revision, transaction)
rendered = render_using(renderer, {:revision => revision})
- path = output_path(revision, rendered)
- File.open(path, 'w') do |file|
- case rendered
- when IO
- IO.copy_stream(rendered, file)
- else
- file.write(rendered.to_s)
- end
- end
+ transaction.store(self, renderer.is_dynamic_template?(rendered), rendered)
end
def output_path(revision, render)
ext = nil
template_dynamic = Spontaneous::Output::Template.is_dynamic?(render)