Skip to content

Commit

Permalink
Make metadata attributes public on template page
Browse files Browse the repository at this point in the history
  • Loading branch information
ssorj committed Jun 2, 2024
1 parent c60c62d commit 092e88e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions python/transom/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,26 +399,26 @@ def handle_starttag(self, tag, attrs):
self.link_targets.add(normalized_url)

class TemplatePage(File):
__slots__ = "_content", "_attributes", "_page_template", "_head_template", "_body_template"
__slots__ = "_content", "metadata", "_page_template", "_head_template", "_body_template"

def _process_input(self):
self._content = read_file(self.input_path)
self._content, self._attributes = extract_metadata(self._content)
self._content, self.metadata = extract_metadata(self._content)

self.title = self._attributes.get("title", self.title)
self.title = self.metadata.get("title", self.title)

try:
self._page_template = load_page_template(self._attributes["page_template"], "")
self._page_template = load_page_template(self.metadata["page_template"], "")
except KeyError:
self._page_template = self.site._page_template

try:
self._head_template = load_page_template(self._attributes["head_template"], "")
self._head_template = load_page_template(self.metadata["head_template"], "")
except KeyError:
self._head_template = self.site._head_template

try:
self._body_template = load_page_template(self._attributes["body_template"], "{{page.content}}")
self._body_template = load_page_template(self.metadata["body_template"], "{{page.content}}")
except KeyError:
self._body_template = self.site._body_template

Expand All @@ -441,7 +441,7 @@ def head(self):

@property
def extra_headers(self):
return self._attributes.get("extra_headers", "")
return self.metadata.get("extra_headers", "")

@property
def body(self):
Expand Down

0 comments on commit 092e88e

Please sign in to comment.