Closed wolfmoritz closed 5 years ago
Oh that's really interesting, I've never seen this issue! What code would I need to duplicate the issue?
Here is repro case that I tested using VS Code version 1.34.0
on a Mac, and Twig Language extension 0.8.3
:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>
{% if block('htmlTitle') is defined %}{{ block('htmlTitle') ~ ' - ' }}{% endif %}
Administration
</title>
<link rel="stylesheet" href="...link-to-file">
<script>
let config = {
dateFormat: "{{ site.settings.dateFormat }}",
weekStart: {{ site.settings.dateFormat == 'mm/dd/yyyy' ? '0' : '1' }},
csrfTokenName: "{{ site.csrf.name }}",
csrfTokenValue: "{{ site.csrf.value }}",
{% block jsConfig '' %}
};
</script>
{% block head '' %}
</head>
<body>
{% include "@admin/includes/_alert.html" %}
<section id="default" class="content-wrapper">
<div class="sidebar">
{% block sidebar '' %}
</div>
<main role="main" class="content">
{% block content '' %}
</main>
</section>
<script src="...link-to-file"></script>
{% block foot '' %}
</body>
</html>
When formatted, the {% block head '' %}
on line 24 is duplicated on the next line. In testing the issue it seems to be related to the <script></script>
block above, which also includes some Twig tags.
This has been fixed in the latest update 👍
In one of my templates I have an empty block short tag as a placeholder, to be extended in other templates:
After formatting, this tag is duplicated causing compile errors: