Sha256: aba4d2d0bc0863eba9b4db026ec6e1c175beaf97db82197b4d46f3f91c17f366

Contents?: true

Size: 855 Bytes

Versions: 3

Compression:

Stored size: 855 Bytes

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
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
machined-1.1.0 lib/machined/helpers/page_helpers.rb
machined-1.0.3 lib/machined/helpers/page_helpers.rb
machined-1.0.2 lib/machined/helpers/page_helpers.rb