lib/spontaneous/page_piece.rb in spontaneous-0.2.0.beta5 vs lib/spontaneous/page_piece.rb in spontaneous-0.2.0.beta6

- old
+ new

@@ -3,10 +3,11 @@ require 'delegate' module Spontaneous class PagePiece < DelegateClass(Page) include Spontaneous::Model::Core::Render + include Spontaneous::Model::Core::ContentHash::PagePieceMethods attr_accessor :owner attr_reader :style_id def initialize(owner, target, style_id) @@ -24,10 +25,15 @@ # Returns: the owning Page object def page owner.page end + # This is used to unwrap pages from their entries within boxes + def to_page + target + end + def id target.id end def depth @@ -40,11 +46,11 @@ def entry self end - def export(user) + def export(user = nil) target.shallow_export(user).merge(export_styles).merge({ :depth => self.depth }) end @@ -72,8 +78,26 @@ target.resolve_style(style_id) end def template(format = :html, renderer = Spontaneous::Output.default_renderer) style.template(format, renderer) + end + + def inspect + %(#<PagePiece target=#{target.inspect}>) + end + + def renderable + self + end + + # Ensure that we map #render* to #render_inline* as this version of a page + # has no non-inline version + def render(format = :html, params = {}, parent_context = nil) + render_inline(format, params, parent_context) + end + + def render_using(renderer, format = :html, params = {}, parent_context = nil) + render_inline_using(renderer, format, params, parent_context) end end end