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
-
.for(origin_or_layout) ⇒ Array<Loaders::Base>
Constructs a list of possible loaders for a Model::RepoOrigin or Layout.
-
.front_matter?(file) ⇒ Boolean
Determines whether a given file has front matter.
-
.register(loader_class) ⇒ void
Registers a new type of front matter loader.
Class Method Details
.for(origin_or_layout) ⇒ Array<Loaders::Base>
Constructs a list of possible loaders for a Model::RepoOrigin or Layout
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
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
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 |