Note that jinja2 syntax allows for proper comments[1] as well. So if you were to comment out a line or a block for any reason, you could also use:
``` {# Comment out emails until we fix deeper issue #{% if env == 'production' %} #'mail_admins', #{% endif %} #} ], ``` Depends, obviously on whether you want the comment to be in the code only, or rendered out in the target file. [1]: https://jinja.palletsprojects.com/en/3.0.x/templates/#comments On Tue, Feb 22, 2022 at 4:11 PM Lpuvilla0001 <lpuvilla0...@mymail.lausd.net> wrote: > Thank you for the tip! Learned something new today. > > +1 > > > > On Feb 22, 2022 at 6:32 AM, <Stephen Smoogen> wrote: > > > I have done this myself a couple of times myself so wanted to be clear > that when you comment out regions in j2 it doesn't act like you would > expect. Basically, j2 decisions end of lines are 'eaten' and the next line > is appended to your previous one. This works great in many places but can > kill you in others. > > A change like this: > ``` > # Comment out emails until we fix deeper issue > #{% if env == 'production' %} > #'mail_admins', > #{% endif %} > ], > ``` > will end up with this: > ``` > # Comment out emails until we fix deeper issue > # #'mail_admins', > # ], > ``` > versus what is expected. If you are commenting out some j2 decision code, > always add either a blank line after words OR an addition comment line at > the end > ``` > # Comment out emails until we fix deeper issues > #{% if env == 'production' %} > #'mail_admins', > #{% endif %} > # > ``` > will go to > ``` > # Comment out emails until we fix deeper issues > # #'mail_admins', > # # > ``` > > The most likely place you will run into this is the giant mess of nagios > configs I left for infrastructure. There are many times where you may need > to comment out a decision to see if it's the place nagios is currently > puking itself.. and you end up with now two places nagios is puking itself. > -- > Stephen Smoogen, Red Hat Automotive > Let us be kind to one another, for most of us are fighting a hard battle. > -- Ian MacClaren > _______________________________________________ infrastructure mailing > list -- infrastructure@lists.fedoraproject.org To unsubscribe send an > email to infrastructure-le...@lists.fedoraproject.org Fedora Code of > Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ > List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines > List Archives: > https://lists.fedoraproject.org/archives/list/infrastructure@lists.fedoraproject.org > Do not reply to spam on the list, report it: > https://pagure.io/fedora-infrastructure > > _______________________________________________ > infrastructure mailing list -- infrastructure@lists.fedoraproject.org > To unsubscribe send an email to > infrastructure-le...@lists.fedoraproject.org > Fedora Code of Conduct: > https://docs.fedoraproject.org/en-US/project/code-of-conduct/ > List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines > List Archives: > https://lists.fedoraproject.org/archives/list/infrastructure@lists.fedoraproject.org > Do not reply to spam on the list, report it: > https://pagure.io/fedora-infrastructure >
_______________________________________________ infrastructure mailing list -- infrastructure@lists.fedoraproject.org To unsubscribe send an email to infrastructure-le...@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/infrastructure@lists.fedoraproject.org Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure