Reputation: 403
I have this basic template structure:
// base.html.twig
{% include "_parts/header.html.twig" %}
{% block body %}{% endblock %}
{% include "_parts/footer.html.twig" %}
I have the setting "Format on save" checked.
Here is the _part/header.html.twig
file:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>
{% block title %}Welcome!{% endblock %}
</title>
{% block stylesheets %}{{ encore_entry_link_tags('app') }}{% endblock %}
{% block javascripts %}{{ encore_entry_script_tags('app') }}{% endblock %}
</head>
<body>
<h3>{{ config('SITE_NAME') }}</h3>
Unfortunatly, on save, the formatter adds closing tags: </body>
and </html>
But those must be in _parts/footer.twig
Also, the formatter is changing:
{% block title %}Welcome!{% endblock %}
into:
{% block title %}
Welcome!
{% endblock %}
Is there a way to disable it for 'block' tag too?
Thank you. Ed
Upvotes: 0
Views: 864
Reputation: 340
I don't know how to do this (i was searching for something similar) but I have a little advice about that: just make sure every template is complete by himself in his structure will ease the task.
For example, a base skeleton beginning with <html>
, ending with </html>
, containing (via include) a header beginning with <head>
, ending with </head>
, same goes for body, and footer, etc.
In your example, the <body>
tag in _parts/header.html.twig
should be in the body, or at least in the base.
This way you will see the template is valid, so will the formatter.
Upvotes: 1