class Awestruct::Handlers::LayoutHandler
Public Class Methods
new(site, delegate)
click to toggle source
Calls superclass method
Awestruct::Handlers::BaseHandler::new
# File lib/awestruct/handlers/layout_handler.rb, line 7 def initialize(site, delegate) super( site, delegate ) end
Public Instance Methods
for_layout_chain(page, &block)
click to toggle source
# File lib/awestruct/handlers/layout_handler.rb, line 32 def for_layout_chain(page, &block) current_page = page $LOG.debug "layout_chain for #{current_page.source_path}" if $LOG.debug? while ( ! ( current_page.nil? || current_page.layout.nil? ) ) current_page = site.layouts.find_matching( current_page.layout, current_page.output_extension ) $LOG.debug "found matching layout for #{current_page}" if $LOG.debug? if ( ! current_page.nil? ) $LOG.debug "calling: #{block.inspect}" if $LOG.debug? block.call( current_page ) end end end
inherit_front_matter(page)
click to toggle source
# File lib/awestruct/handlers/layout_handler.rb, line 25 def inherit_front_matter(page) delegate.inherit_front_matter( page ) for_layout_chain(page) do |layout| page.inherit_front_matter_from( layout ) end end
input_mtime(page)
click to toggle source
# File lib/awestruct/handlers/layout_handler.rb, line 11 def input_mtime(page) t = delegate.input_mtime( page ) for_layout_chain(page) do |layout| layout_mtime = layout.input_mtime if ( t == nil ) t = layout_mtime elsif ( layout_mtime > t ) t = layout_mtime end end page_mtime = delegate.input_mtime( page ) t end
rendered_content(context, with_layouts=true)
click to toggle source
# File lib/awestruct/handlers/layout_handler.rb, line 45 def rendered_content(context, with_layouts=true) $LOG.debug "rendering content with layout #{with_layouts} for #{context.page.output_path}" if $LOG.debug? content = delegate.rendered_content( context, with_layouts ) if ( with_layouts ) $LOG.debug "calling for_layout_chain" if $LOG.debug? for_layout_chain(context.__effective_page || context.page) do |layout| context.content = content context.__effective_page = layout context[:__is_layout] = true content = layout.rendered_content( context, false ) end end $LOG.debug "finished rendering content for #{context.page.output_path}" if $LOG.debug? content end