Skip to content

Instantly share code, notes, and snippets.

@khanfarhan10
Forked from Atlas7/blog.md
Created August 13, 2023 22:10
Show Gist options
  • Save khanfarhan10/a84e6d3fa58302c23cd22b7048b42754 to your computer and use it in GitHub Desktop.
Save khanfarhan10/a84e6d3fa58302c23cd22b7048b42754 to your computer and use it in GitHub Desktop.
Inline commenting within a Jinja2 HTML template

Learnt something new today. If we are to perform an inline commenting within a Jinja2 HTMl template...

The following will be rendered as a comment - via the {# and #} tags.

{# {{ Hello World }} #}

The following however may cause problem - because Jinja2 will try to parse the Python variable Hello and World, which may not exist.

<!-- {{ Hello World }} -->

Observation: we may use this feature to our advantage - e.g. to dynamic generate HTML comments with the above syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment