Jinja2 comment block. Anything placed between these comment tags will be ignored by the templating engine and will not be rendered in the final output. Mar 6, 2024 · To comment-out part of a line in a template, use the comment syntax which is by default set to {# #}. Jinja2 has no support for comments within a {{ }} statement. You can only use comments outside of such statements, and then only with {# . To use them, set line_statement_prefix and line_comment_prefix when creating the Environment. This is useful to comment out parts of the template for debugging or to add information for other template designers or yourself:,7. Nov 23, 2024 · Use {# comment #} for comments that need to be entirely outside of any Jinja2 expressions, ensuring they do not disrupt the syntax. To put comments inside Jinja2 argument list declaration, you can use the {% comment %} macro to create a comment block within the Jinja2 argument list. For example, you could define a Jinja2 macro that takes an argument and creates an inline comment block at the end of the argument list: Jul 23, 2025 · Add comments to your templates to provide context and explanations for other developers (or your future self). 4. There are a few kinds of delimiters. Apr 4, 2024 · In Jinja2, inline comments are denoted by the {# #} syntax. Line statements with # (if line statements are enabled) can be used but with caution, as they strictly apply to non-Jinja2 syntax. #} or ## comment. Use Jinja's comment syntax {# This is a comment #} to clarify the purpose of specific sections or code blocks within your templates. The default Jinja delimiters are configured as follows: Line Statements and Comments are also possible, though they don’t have default prefix characters. . pruxepg gmktj qud jhltm zuyl sjpu iknraj ngyfa gplp mmir