Sha256: 1a2715cad61019cbc87fcc1683789e0f831cee99803a1fffcd340e283a02ebde

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

require "active_support/core_ext/string/inflections"

module Machined
  module Helpers
    module PageHelpers
      # Returns the default layout, unless overridden by
      # the YAML front matter.
      def layout
        if has_local? :layout
          locals[:layout]
        else
          machined.config.layout
        end
      end
      
      # Returns the local variable, title, if set. Otherwise
      # return a titleized version of the filename.
      def title
        if has_local? :title
          locals[:title]
        else
          File.basename(logical_path).titleize
        end
      end
    
      # Returns the URL to this asset, appending the sprocket's URL.
      # For HTML files, this will return pretty URLs.
      def url
        File.join(environment.config.url, @logical_path).sub /(index)?\.html$/, ''
      end
      
      protected
      
      # Returns a hash where we store found contexts.
      def contexts_cache # :nodoc:
        @contexts_cache ||= {}
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
machined-0.6.0 lib/machined/helpers/page_helpers.rb
machined-0.5.0 lib/machined/helpers/page_helpers.rb