Sha256: 480160df921f6ee08b12dc2852d6e82454ba138a4d544f51280782eabac25679

Contents?: true

Size: 854 Bytes

Versions: 1

Compression:

Stored size: 854 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

1 entries across 1 versions & 1 rubygems

Version Path
machined-1.0.1 lib/machined/helpers/page_helpers.rb