Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tag name variables closing error #42

Open
seb-b opened this issue Oct 10, 2024 · 1 comment
Open

Tag name variables closing error #42

seb-b opened this issue Oct 10, 2024 · 1 comment

Comments

@seb-b
Copy link

seb-b commented Oct 10, 2024

I'm not even sure if this is a use-case that should be covered by this plugin, it's pretty niche, but we have a macro that looks something like this

{% macro button_link(text, url=None) %}
	{% set element_type = "a" if url else "button" %}
	<{{ element_type }}
	{% if element_type == "a" %}
		href="{{ url }}"
	{% endif %}> {{ text }}
    </{{ element_type }}>
{% endmacro %}

Will come up with a Unexpected closing tag error from prettier. Wrapping just the closing </{{ element_type }}> in ignore tags fixes the problem, which means it must think the first tag is self-closing?

prettier error:

SyntaxError: Unexpected closing tag "#~9~#". It may happen when the tag has already been closed by another tag. For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags (5:5)
  3 | 	<#~3~#
  4 | 	#~7~#> #~8~#
> 5 |     </#~9~#>
    |     ^^^^^^^^
  6 |
@johannesloibl
Copy link

Same here:

{% for artifact in artifacts %}
  {% if loop.last and next_page|default('') %}
    <tr
      class="hover"
      hx-get="{{ next_page }}"
      hx-trigger="revealed"
      hx-swap="afterend"
    >
  {% else %}
    <tr class="hover">
  {% endif %}
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
</tr>
{% endfor %}

Gives SyntaxError: Unexpected closing tag "tr"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants