-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove the Document subclass, use the Metadata include
- Loading branch information
Showing
3 changed files
with
30 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative 'document' | ||
|
||
module Dimples | ||
class Page < Document | ||
# A class representing a single page on a site. | ||
class Page | ||
include Metadata | ||
|
||
def initialize(path: nil, metadata: {}) | ||
@path = path | ||
@metadata = {} | ||
@contents = '' | ||
|
||
load_metadata(path) if path | ||
@metadata.merge!(metadata) unless metadata.empty? | ||
end | ||
|
||
def layout | ||
@metadata.fetch(:layout, 'page') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative 'document' | ||
|
||
module Dimples | ||
class Template < Document | ||
# A class representing a single template used for a layout on a site. | ||
class Template | ||
include Metadata | ||
|
||
def initialize(path:) | ||
@path = path | ||
load_metadata(path) | ||
end | ||
end | ||
end |