8000 Invalid minified output when minifying Jinja template (brace_template_syntax) · Issue #232 · wilsonzlin/minify-html · GitHub
[go: up one dir, main page]

Skip to content
8000

Invalid minified output when minifying Jinja template (brace_template_syntax) #232

Open

Description

@Zaczero

Code

https://pypi.org/project/minify-html - v0.16.4

minify(source, preserve_brace_template_syntax=True)

Before

<body class="{% block body_class %}{% endblock %}" {% block body_attrs %}{% endblock %}></body>

After

<body class="{% block body_class %}{% endblock %}" %} %}{% block body_attrs endblock {%>

Activity

  1. Zaczero commented on Apr 11, 2025

    @Zaczero
    Author

    It appears that the parser doesn't recognize template syntax in attribute part. This is likely the same issue as #183.

  2. Zaczero commented on Apr 11, 2025

    @Zaczero
    Author

    Seems like the comments are also broken when placed as attributes and keep_comments=True

  3. AshfordN commented on Apr 21, 2026

    @AshfordN

    I am experiencing this problem as well with the sailfish syntax. My command, input and output are shown below.

    command
    minhtml --keep-closing-tags --preserve-chevron-percent-template-syntax input.stpl

    input.stpl

    <select>
        <option value="first" <% if condition {%>selected<% }%>>First</option>
    </select>
    

    output

    <select><option <% condition if value=first {%>;selected<% }%>>First</option></select>
    

    There seems to be clever ways to progressively work around the issue. For example, removing the space before the template closing tag prevents some of the distortion highlighted in the earlier example, and I can actually get the above code to work if I change the order of the attributes. However, none of those fixes feel elegant and reliable. It feels like relying on quirks in the code. I am also not sure if any of this is intended behavior, so I am hoping that someone more familiar with the project could offer some guidance here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0