diff --git a/djlint/formatter/indent.py b/djlint/formatter/indent.py index bd37219da..b6b6d9b48 100644 --- a/djlint/formatter/indent.py +++ b/djlint/formatter/indent.py @@ -88,19 +88,22 @@ def fix_handlebars_template_tags( ignored_level = 0 for item in rawcode_flat_list: + is_safe_closing_tag_ = is_safe_closing_tag(config, item) + is_ignored_block_opening_ = is_ignored_block_opening(config, item) + # if a raw tag first line - if not is_block_raw and is_ignored_block_opening(config, item): + if not is_block_raw and is_ignored_block_opening_: is_raw_first_line = True # if a raw tag then start ignoring - if is_ignored_block_opening(config, item): + if is_ignored_block_opening_: is_block_raw = True ignored_level += 1 if is_script_style_block_opening(config, item): in_script_style_tag = True - if is_safe_closing_tag(config, item): + if is_safe_closing_tag_: ignored_level -= 1 ignored_level = max(ignored_level, 0) if is_block_raw and ignored_level == 0: @@ -183,7 +186,7 @@ def fix_handlebars_template_tags( flags=re.IGNORECASE | re.MULTILINE | re.VERBOSE, ) and not is_block_raw - and not is_safe_closing_tag(config, item) + and not is_safe_closing_tag_ # and not ending in a slt like . and not re.findall( rf"(<({slt_html})>)(.*?)([^<]*?$)", @@ -261,9 +264,7 @@ def fix_handlebars_template_tags( tmp = (indent * indent_level) + item + "\n" indent_level += 1 - elif is_raw_first_line or ( - is_safe_closing_tag(config, item) and not is_block_raw - ): + elif is_raw_first_line or (is_safe_closing_tag_ and not is_block_raw): tmp = (indent * indent_level) + item + "\n" elif is_block_raw or not item.strip(): @@ -279,7 +280,7 @@ def fix_handlebars_template_tags( # if a opening raw tag then start ignoring.. only if there is no closing tag # on the same line - if is_ignored_block_opening(config, item): + if is_ignored_block_opening_: is_block_raw = True is_raw_first_line = False @@ -302,7 +303,7 @@ def fix_handlebars_template_tags( or is_script_style_block_closing(config, item) ): in_script_style_tag = False - if not is_safe_closing_tag(config, item): + if not is_safe_closing_tag_: ignored_level -= 1 ignored_level = max(ignored_level, 0) if ignored_level == 0: