0
@@ -24,7 +24,6 @@ class Renderer
0
- class Error < StandardError; end
0
@@ -40,7 +39,7 @@ class Renderer
0
::File.open(page.destination, 'w') do |fd|
0
- fd.write
renderer.layout_page0
+ fd.write
(renderer.__send__(:_layout_page))0
break unless renderer.__send__(:_next_page)
0
@@ -69,40 +68,6 @@ class Renderer
0
- # layout_page => string
0
- # Apply the desired filters to the page and then render the filtered page
0
- # into the desired layout. The filters to apply to the page are determined
0
- # from the page's meta-data. The layout to use is also determined from the
0
- layouts = Resources.layouts
0
- str = @page.render(self)
0
- lyt = layouts.find :filename => obj.layout
0
- @content, str = str, ::Webby::Resources::File.read(lyt.path)
0
- str = _track_rendering(lyt.path) {
0
- Filters.process(self, lyt, str)
0
- @content, obj = nil, lyt
0
- @@stack.pop if @page.path == @@stack.last
0
- raise Error, "rendering stack corrupted" unless @@stack.empty?
0
- @log.error "while rendering page '#{@page.path}'"
0
# render_page => string
0
# Apply the desired filters to the page. The filters to apply are
0
@@ -136,11 +101,11 @@ class Renderer
0
p = Resources.partials.find(
0
:filename => fn, :in_directory => @page.dir ) rescue nil
0
p ||= Resources.partials.find(:filename => fn)
0
- raise
Error, "could not find partial '#{part}'" if p.nil?
0
+ raise
::Webby::Error, "could not find partial '#{part}'" if p.nil?
0
when ::Webby::Resources::Partial
0
- else raise
Error, "expecting a partial or a partial name" end
0
+ else raise
::Webby::Error, "expecting a partial or a partial name" end
0
_track_rendering(part.path) {
0
Filters.process(self, part, ::Webby::Resources::File.read(part.path))
0
@@ -182,6 +147,52 @@ class Renderer
0
+ # _layout_page => string
0
+ # Apply the desired filters to the page and then render the filtered page
0
+ # into the desired layout. The filters to apply to the page are determined
0
+ # from the page's meta-data. The layout to use is also determined from the
0
+ @content = @page.render(self)
0
+ _track_rendering(@page.path) {
0
+ _render_layout_for(@page)
0
+ raise ::Webby::Error, "rendering stack corrupted" unless @@stack.empty?
0
+ rescue ::Webby::Error => err
0
+ @log.error "while rendering page '#{@page.path}'"
0
+ @log.error err.message
0
+ @log.error "while rendering page '#{@page.path}'"
0
+ # _render_layout_for( resource )
0
+ # Render the layout for the given resource. If the resource does not have
0
+ # a layout, then this method returns immediately.
0
+ def _render_layout_for( res )
0
+ lyt = Resources.layouts.find :filename => res.layout
0
+ _track_rendering(lyt.path) {
0
+ @content = Filters.process(
0
+ self, lyt, ::Webby::Resources::File.read(lyt.path))
0
+ _render_layout_for(lyt)
0
# _next_page => true or false
0
# Returns +true+ if there is a next page to render. Returns +false+ if
0
@@ -222,7 +233,7 @@ class Renderer
0
msg = "rendering loop detected for '#{path}'\n"
0
msg << " current rendering stack\n\t"
0
msg << @@stack.join("\n\t")
0
+ raise
::Webby::Error, msg
Comments
No one has commented yet.