Skip to content

Commit

Permalink
Fix registration system
Browse files Browse the repository at this point in the history
  • Loading branch information
timvink authored Sep 13, 2024
1 parent ddace97 commit 03f5e89
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions mkdocs_macros/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def raw_markdown(self, value):
# ----------------------------------
# Hooks for other applications
# ----------------------------------
def register_macro(self, items:dict):
def register_macros(self, items:dict):
"""
Register macros (hook for other plugins).
These will be added last, and raise an exception if already present.
Expand All @@ -336,22 +336,25 @@ def register_macro(self, items:dict):
# after on_config
self._macros
register_items('macro', self.macros, items)
self.variables["macros"].update(self.macros)
self.env.globals.update(self.macros)
except AttributeError:
# before on_config: store for later
self._add_macros += items
self._add_macros.update(items)

def register_filters(self, items:dict):
"""
Register filters (hook for other plugins).
These will be added last, and raise an exception if already present.
"""
try:
# after on_config
self._filters
register_items('filter', self.filters, items)
self.variables["filters"].update(self.filters)
self.env.filters.update(self.filters)
except AttributeError:
# before on_config: store for later
self._add_filters += items
self._add_filters.update(items)

def register_variables(self, items:dict):
"""
Expand All @@ -364,7 +367,7 @@ def register_variables(self, items:dict):
register_items('variables', self.variables, items)
except AttributeError:
# before on_config: store for later
self._add_variables += items
self._add_variables.update(items)

# ----------------------------------
# Function lists, for later events
Expand Down

0 comments on commit 03f5e89

Please sign in to comment.