Field strip outer
This module provides a simple way for themers to remove outer divs from fields directly from Manage display formatter settings.
You only have to override field.html.twig and you can have surrounding field divs for one field in one display and remove them in another display. No other field template override is required.
Installation
Install this module normally, just like you would install a contributed Drupal module. Visit https://www.drupal.org/node/1897420 for further information.
If you don't have one, create a custom theme (https://www.drupal.org/docs/theming-drupal).
Copy field.html.twig from drupal core (web/core/modules/system/templates/field.html.twig) or from the parent theme or your theme.
Use the code following code snippet to have both stripped or normal DOM version :
{% if stripouter_valueonly %}:
{% for item in items %}
{{ item.content }}
{% endfor %}
{% else %}
<!-- content from field.html.twig -->
{% endif %}Clear your cache.
Go to your content type "Manage display" tab and edit your field display setting to control DOM output for one view mode or another.
Other modules :
Please consider using No Markup module first as it have more installations.
We still continue to maintain this module.
Depends on
Dependencies of the latest stable release
No dependencies recorded for this project.
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.
Activity
Releases
| Version | Type | Core | Release date | |
|---|---|---|---|---|
| 1.0.0 | Stable | Oct 17, 2023 |