Module: Bridgetown::FrontMatter::Loaders

Defined in:
bridgetown-core/lib/bridgetown-core/front_matter/loaders.rb,
bridgetown-core/lib/bridgetown-core/front_matter/loaders/base.rb,
bridgetown-core/lib/bridgetown-core/front_matter/loaders/ruby.rb,
bridgetown-core/lib/bridgetown-core/front_matter/loaders/yaml.rb

Defined Under Namespace

Classes: Base, Result, Ruby, YAML

Class Method Summary collapse

Class Method Details

.for(origin_or_layout) ⇒ Array<Loaders::Base>

Constructs a list of possible loaders for a Model::RepoOrigin or Layout

Parameters:

Returns:



16
17
18
# File 'bridgetown-core/lib/bridgetown-core/front_matter/loaders.rb', line 16

def self.for(origin_or_layout)
  registry.map { |loader_class| loader_class.new(origin_or_layout) }
end

.front_matter?(file) ⇒ Boolean

Determines whether a given file has front matter

Parameters:

  • path (Pathname, String)

    the path to the file

Returns:

  • (Boolean)

    true if the file has front matter, false otherwise



24
25
26
# File 'bridgetown-core/lib/bridgetown-core/front_matter/loaders.rb', line 24

def self.front_matter?(file)
  registry.any? { |loader_class| loader_class.header?(file) }
end

.register(loader_class) ⇒ void

This method returns an undefined value.

Registers a new type of front matter loader

Parameters:

  • loader_class (Loader::Base)


32
33
34
# File 'bridgetown-core/lib/bridgetown-core/front_matter/loaders.rb', line 32

def self.register(loader_class)
  registry.push(loader_class)
end