Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I comment in a Jinja directive?

Tags:

jinja2

I have a Jinja set directive as follows:

{% set mylist = [
  "item 1",
  "another item",
  "yet another item",
] %}

I would like to add a comment to the second list item. Does Jinja support that? I've tried the following:

{% set mylist = [
  "item 1",
  "another item",  # My comment
  "yet another item",
] %}

and

{% set mylist = [
  "item 1",
  "another item",  ## My comment
  "yet another item",
] %}

, but none of them work. I'm using Jinja 2.6.

like image 436
Ztyx Avatar asked Sep 30 '15 08:09

Ztyx


1 Answers

No, Jinja does not support inline comments. However, you can use a comment block:

{#
BUG: Added "another item" because of raisins.
Don't remove it until #12345 is fixed
#}
{% set mylist = [
  "item 1",
  "another item",
  "yet another item",
] %}
like image 52
Sean Vieira Avatar answered Sep 20 '22 20:09

Sean Vieira