Sha256: e9a039acd0088204a5795b58f4875c041dfe34c0f4c2205f6c3043dc611ffd33

Contents?: true

Size: 1.04 KB

Versions: 7

Compression:

Stored size: 1.04 KB

Contents

module Locomotive::Steam
  module Adapters
    module Filesystem

      module YAMLLoader

        attr_reader :site_path

        def initialize(site_path)
          @site_path = site_path
        end

        def load(scope = nil)
          @scope = scope
        end

        def default_locale
          @scope.default_locale
        end

        def _load(path, frontmatter = false, &block)
          if File.exists?(path)
            yaml      = File.open(path).read.force_encoding('utf-8')
            template  = nil

            if frontmatter && match = yaml.match(FRONTMATTER_REGEXP)
              yaml, template = match[:yaml], match[:template]
            end

            HashConverter.to_sym(YAML.load(yaml)).tap do |attributes|
              block.call(attributes, template) if block_given?
            end
          else
            Locomotive::Common::Logger.error "No #{path} file found"
            {}
          end
        end

        def template_extensions
          @extensions ||= %w(liquid haml)
        end

      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
locomotivecms_steam-1.0.0.pre.beta.3 lib/locomotive/steam/adapters/filesystem/yaml_loader.rb
locomotivecms_steam-1.0.0.pre.beta.2 lib/locomotive/steam/adapters/filesystem/yaml_loader.rb
locomotivecms_steam-1.0.0.pre.beta.1 lib/locomotive/steam/adapters/filesystem/yaml_loader.rb
locomotivecms_steam-1.0.0.pre.alpha.3 lib/locomotive/steam/adapters/filesystem/yaml_loader.rb
locomotivecms_steam-1.0.0.pre.alpha.2 lib/locomotive/steam/adapters/filesystem/yaml_loader.rb
locomotivecms_steam-1.0.0.pre.alpha.1 lib/locomotive/steam/adapters/filesystem/yaml_loader.rb
locomotivecms_steam-1.0.0.pre.alpha lib/locomotive/steam/adapters/filesystem/yaml_loader.rb