Skip to content

Instantly share code, notes, and snippets.

@Atlas7
Created January 5, 2016 20:16
Show Gist options
  • Save Atlas7/d35eed7efb4e085c4343 to your computer and use it in GitHub Desktop.
Save Atlas7/d35eed7efb4e085c4343 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