Sha256: 271af712609f9e643e2e4402e2cff5a288a455d1f52b5d812f0fcf997c4d9ce4

Contents?: true

Size: 1.48 KB

Versions: 3

Compression:

Stored size: 1.48 KB

Contents

require Webby.libpath(*%w[webby resources resource])

module Webby::Resources

# A Layout is any file that is found in the layout folder of the webiste
# directory. Layouts container the common elements of all the pages in a
# website, and pages from the content folder are rendered into the layout.
#
class Layout < Resource

  # call-seq:
  #    Layout.new( path )
  #
  # Creates a new Layout object given the full path to the layout file.
  #
  def initialize( fn )
    super

    @mdata = ::Webby::Resources::File.meta_data(@path)
    @mdata ||= {}
    @mdata.sanitize!
  end

  # call-seq:
  #    destination    => string
  #
  # The output file destination for the layout. This is the ".cairn" file in
  # the output folder. It is used to determine if the layout is newer than
  # the build products.
  #
  def destination
    ::Webby.cairn
  end

  # call-seq:
  #    extension    => string or nil
  #
  # Returns the extension to be applied to output files rendered by the
  # layotut. This will either be a string or +nil+ if the layout does not
  # specify an extension to use.
  #
  def extension
    return @mdata['extension'] if @mdata.has_key? 'extension'

    if @mdata.has_key? 'layout'
      lyt = ::Webby::Resources.find_layout(@mdata['layout'])
      ext = lyt ? lyt.extension : nil
    end
  end

  # call-seq:
  #    url    => nil
  #
  # Layouts do not have a URL. This method will alwasy return +nil+.
  #
  def url
    nil
  end

end  # class Layout
end  # module Webby::Resources

# EOF

Version data entries

3 entries across 3 versions & 3 rubygems

Version Path
Shazburg-webby-0.9.0 lib/webby/resources/layout.rb
TwP-webby-0.9.0 lib/webby/resources/layout.rb
webby-0.9.0 lib/webby/resources/layout.rb