可以通过用 djLint 标签包裹代码来跳过代码检查或格式化:
对于传统 HTML -
<!-- djlint:off -->
<bad html to ignore> <!-- djlint:on --></bad>
或使用注释 -
{# djlint:off #} <bad html to ignore> {# djlint:on #}</bad>
或使用长注释 -
{% comment %} djlint:off {% endcomment %}
<bad html to ignore> {% comment %} djlint:on {% endcomment %}</bad>
亦或是 javascript 风格注释 -
{{ /* djlint:off */ }} <bad html to ignore> {{ /* djlint:on */ }}</bad>
以及 golang 风格注释 -
{{!-- djlint:off --}} <bad html to ignore> {{!-- djlint:on --}}</bad>
通过在忽略块的开始标签中添加规则名,可以忽略特定的代码检查规则。
{# djlint:off H025,H026 #}
<p>
{# djlint:on #}
<!-- djlint:off H025-->
</p>
<p>
<!-- djlint:on -->
{% comment %} djlint:off H025 {% endcomment %}
</p>
<p>{% comment %} djlint:on {% endcomment %} {{!-- djlint:off H025 --}}</p>
<p>{{!-- djlint:on --}} {{ /* djlint:off H025 */ }}</p>
<p>{{ /* djlint:on */ }}</p>