zulip/templates
Alex Vandiver fa6daee4e1 markdown: Fix use of pure_markdown for non-pure markdown rendering.
`render_markdown_path` renders Markdown, and also (since baff121115)
runs Jinja2 on the resulting HTML.

The `pure_markdown` flag was added in 0a99fa2fd6, and did two
things: retried the path directly in the filesystem if it wasn't found
by the Jinja2 resolver, and also skipped the subsequent Jinja2
templating step (regardless of where the content was found).  In this
context, the name `pure_markdown` made some sense.  The only two
callsites were the TOS and privacy policy renders, which might have
had user-supplied arbitrary paths, and we wished to handle absolute
paths in addition to ones inside `templates/`.

Unfortunately, the follow-up of 01bd55bbcb did not refactor the
logic -- it changed it, by making `pure_markdown` only do the former
of the two behaviors.  Passing `pure_markdown=True` after that commit
still caused it to always run Jinja2, but allowed it to look elsewhere
in the filesystem.

This set the stage for calls, such as the one introduced in
dedea23745, which passed both a context for Jinja2, as well as
`pure_markdown=True` implying that Jinja2 was not to be used.

Split the two previous behaviors of the `pure_markdown` flag, and use
pre-existing data to control them, rather than an explicit flag.  For
handling policy information which is stored at an absolute path
outside of the template root, we switch to using the template search
path if and only if the path is relative.  This also closes the
potential inconsistency based on CWD when `pure_markdown=True` was
passed and the path was relative, not absolute.

Decide whether to run Jinja2 based on if a context is passed in at
all.  This restores the behavior in the initial 0a99fa2fd6 where a
call to `rendar_markdown_path` could be made to just render markdown,
and not some other unmentioned and unrelated templating language as
well.
2023-03-17 08:46:25 -07:00
..
analytics analytics-realm-activity: Add link to realm's stats page. 2022-12-02 17:30:30 -08:00
confirmation google_analytics: Track realm registration separately from user signup. 2023-03-08 11:34:36 -08:00
corporate portico: Link to new "Try Zulip" page from TUM case study. 2023-03-14 13:21:09 -07:00
tests
two_factor templates: Prevent dangling end tags. 2021-11-23 15:55:54 -08:00
zerver markdown: Fix use of pure_markdown for non-pure markdown rendering. 2023-03-17 08:46:25 -07:00
zilencer
.gitignore
404.html templates: Use static() helper to generate /static/ URLs. 2023-02-14 17:17:06 -05:00
500.html templates: Use static() helper to generate /static/ URLs. 2023-02-14 17:17:06 -05:00