Sha256: 1677e97978ae56aaa7b112b69f1fd72bd486cb801d889b9437bd69dfe77c3dee

Contents?: true

Size: 864 Bytes

Versions: 6

Compression:

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

6 entries across 6 versions & 1 rubygems

Version Path
machined-1.0.0 lib/machined/helpers/page_helpers.rb
machined-0.9.3 lib/machined/helpers/page_helpers.rb
machined-0.9.2 lib/machined/helpers/page_helpers.rb
machined-0.9.1 lib/machined/helpers/page_helpers.rb
machined-0.9.0 lib/machined/helpers/page_helpers.rb
machined-0.8.0 lib/machined/helpers/page_helpers.rb