jacerider/neo_twig

Provides twig helpers.

Installs: 67

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:drupal-module

1.0.9 2024-12-04 15:01 UTC

This package is auto-updated.

Last update: 2024-12-04 15:02:02 UTC


README

  • Introduction
  • Requirements
  • Installation
  • Tools

INTRODUCTION

Provides twig helpers for Drupal.

REQUIREMENTS

This module requires no modules outside of Drupal core.

INSTALLATION

Install as you would normally install a contributed Drupal module. Visit https://www.drupal.org/node/1897420 for further information.

TOOLS

Class

Add a class to an element.

{{ field_image|neo_class('bg-base-500') }}

Class to Children

Add a class to an children of a renderable.

{{ field_images|neo_child_class('bg-base-500') }}

You can also target nested elements within a child by defining the path to the nested element.

{{ field_images|neo_child_class('bg-base-500', ['images', 'image', '#attributes']) }}

Children

Get children of a content field.

<ul>
  {% for tag in content.field_tags|neo_children %}
    <li>{{ tag }}</li>
  {% endfor %}
</ul>

Field

Render a field from a nested entity reference field.

{% for key, item in content.field_reference|neo_children %}
  {{ item|neo_field('field_image') }}
{% endfor %}