mblode / mblode/vscode-twig-language
Twig Block Shorthand Synatx Indentation
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 45
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
The latest release 0.8.7 did not fix the indentation issue with using Twig block shorthand syntax issue #15. I still see unexpected block and HTML indentation. Also, closing HTML tags are often indented past the opening tag, and do not match in column.
For example, this HTML:
<!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">
{% block head '' %}
</head>
<body>
{% include "@admin/includes/_alert.html" %}
{% block maintTitle 'CMS' %}
{% block leadText 'Lead text goes here...' %}
<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>
Is formatted like this:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">
<title>
{% if block('htmlTitle') is defined %}
{{ block('htmlTitle') ~ ' - ' }}
{% endif %}
Administration
</title>
<link href="...link-to-file" rel="stylesheet">
{% block head '' %}
</head>
<body>
{% include "@admin/includes/_alert.html" %}
{% block maintTitle 'CMS' %}
{% block leadText 'Lead text goes here...' %}
<section class="content-wrapper" id="default">
<div class="sidebar">
{% block sidebar '' %}
</div>
<main class="content" role="main">
{% block content '' %}
</main>
</section>
<script src="...link-to-file"></script>
{% block foot '' %}
</body>
</html>
Note the extra indent on the {% block leadText %}, and the closing tags on body, section, and div.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the formatter behavior described in issue #15 with the supplied input and output examples in this issue. Reproduce the Twig block shorthand case in the extension, then verify that nested blocks and HTML closing tags retain the intended indentation and column alignment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, vscode
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100