mirror of https://github.com/zulip/zulip.git
templates: Use Dict instead of Mapping for the context parameter.
According to the Django documentation, `Template.render` expects a `dict`. See also: https://docs.djangoproject.com/en/4.0/topics/templates/#django.template.backends.base.Template.render. Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
parent
e950b94ab5
commit
0dfec6b132
|
@ -1,5 +1,5 @@
|
||||||
import time
|
import time
|
||||||
from typing import Any, List, Mapping, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
import markdown
|
import markdown
|
||||||
import markdown.extensions.admonition
|
import markdown.extensions.admonition
|
||||||
|
@ -82,13 +82,15 @@ docs_without_macros = [
|
||||||
@items_tuple_to_dict
|
@items_tuple_to_dict
|
||||||
@register.filter(name="render_markdown_path", is_safe=True)
|
@register.filter(name="render_markdown_path", is_safe=True)
|
||||||
def render_markdown_path(
|
def render_markdown_path(
|
||||||
markdown_file_path: str, context: Mapping[str, Any] = {}, pure_markdown: bool = False
|
markdown_file_path: str, context: Optional[Dict[str, Any]] = None, pure_markdown: bool = False
|
||||||
) -> str:
|
) -> str:
|
||||||
"""Given a path to a Markdown file, return the rendered HTML.
|
"""Given a path to a Markdown file, return the rendered HTML.
|
||||||
|
|
||||||
Note that this assumes that any HTML in the Markdown file is
|
Note that this assumes that any HTML in the Markdown file is
|
||||||
trusted; it is intended to be used for documentation, not user
|
trusted; it is intended to be used for documentation, not user
|
||||||
data."""
|
data."""
|
||||||
|
if context is None:
|
||||||
|
context = {}
|
||||||
|
|
||||||
# We set this global hackishly
|
# We set this global hackishly
|
||||||
from zerver.lib.markdown.help_settings_links import set_relative_settings_links
|
from zerver.lib.markdown.help_settings_links import set_relative_settings_links
|
||||||
|
|
Loading…
Reference in New Issue