Twig tweak | Drupal 8 Project | Drupal 8

Twig tweak | Drupal 8 Project

Project Name : Twig tweak project Link : Twig tweak
Created : 2016-03-12
Last Update : 2018-07-18
Current Version : 8.x-2.1
Download Twig tweak 8.x-2.1 Version From : Download

Twig Tweak module provides a Twig extension with some useful functions and filters that can improve development experience.

<dl class="examples">    {# You can pass arguments to the view if needed. #}   <dt>View:</dt>   <dd>{{ drupal_view('view_name', 'page_1') }}<dd>    {# To hide the block on other pages put it to 'Disabled' region. #}   <dt>Block:</dt>   <dd>{{ drupal_block('bartik_powered') }}<dd>    {# It can be any content entity. #}   <dt>Entity:</dt>   <dd>{{ drupal_entity('node', 1, 'teaser') }}<dd>    {# You can load an entity from the current route. #}   <dt>Entity from route:</dt>   <dd>{{ drupal_entity('node', null, 'teaser') }}<dd>    {# Use token API to deliver data to your templates. #}   <dt>Token:</dt>   <dd>{{ drupal_token('site:name') }}<dd>    {# Another way to get site name. #}   <dt>Config:</dt>   <dd>{{ drupal_config('', 'name') }}<dd>    {# Welcome back old friend! #}   <dt>PHP filter:</dt>   <dd class="bad-practice">© {{ 'return date("Y");' | php }}<dd>    {# Replace multiple tokens at once. #}   <dt>Token replace:</dt>   <dd>{{ '<h1>[site:name]</h1><div>[site:slogan]</div>' | token_replace }}<dd>    {# The easiest way to alter their output. #}   <dt>Preg replace:</dt>   <dd>{{ 'Drupal - community plumbing!' | preg_replace('/(Drupal)/', '<b>$1</b>') }}</dd>  <dl>