2017 © Pedro Peláez
 

drupal-module drupal_twig_food

Useful functions, filters for twig @ Drupal 8

image

burdapraha/drupal_twig_food

Useful functions, filters for twig @ Drupal 8

  • Thursday, April 5, 2018
  • by landsman
  • Repository
  • 1 Watchers
  • 14 Stars
  • 1,688 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 4 Open issues
  • 5 Versions
  • 5 % Grown

The README.md

DrupalTwigFood

Useful functions, filters for twig @ Drupal 8, (*1)

Instalation

Recomended using is via Composer: composer require burdapraha/drupal_twig_food ... and install module "Burda Twig Food" in administration (domain.tld/admin/modules), (*2)

Documentation

The best documentation is easy examples, right? :-), (*3)

Functions

- svg($path)

offering comfortably using svg images in templates, example: {{ svg('awesome_icon.svg') }} when file is stored in "/your-theme-name/images/awesome_icon.svg" and source code of svg will be printed to page as is. This solution is quick and you can use CSS features like ".your-div svg {fill: red}" etc., (*4)

- load_block($id)

you can call block by name anywhere in template: {{ load_block('machine_name') }}, (*5)

- load_region($id)

this function offers print all block of the region anywhere you need: {{ load_region('machine_name') }}, (*6)

- load_main_node($returnId = true)

solving problem with getting node id from anywhere template when you need it {{ load_main_node() }}, (*7)

array with previous media gallery: {{ load_gallery_prev(2) }}, (*8)

array with next media media: {{ load_gallery_next(1) }}, (*9)

array with images from gallery: {{ load_gallery_thumbs(5) }}, (*10)


Filters

- naked_field

return rendered field, for example from view, without developers suggestions (<!-- Hook: etc --->), without HTML tags like <a href="xy">your_filed</a>. Just naked string what you can use as class, data attribute or in twig condition! Using example: {% set badge = content.field_show_badge|naked_field %}, (*11)

- max_length($max = 0, $dots = true)

Check string length and return him summary or in original. It is pretty alternative to ugly {{ teaser_text|length > 90 ? teaser_text|slice(0, 90) ~ ' ...' : teaser_text }}. By second parameter you can disable adding "..." to the end of string., (*12)

The Versions

05/04 2018

dev-development

dev-development https://github.com/BurdaPraha/DrupalTwigFood

Useful functions, filters for twig @ Drupal 8

  Sources   Download

MIT GPL-2.0+

26/02 2018

dev-master

9999999-dev https://github.com/BurdaPraha/DrupalTwigFood

Useful functions, filters for twig @ Drupal 8

  Sources   Download

MIT GPL-2.0+

16/01 2018

1.0.1

1.0.1.0 https://github.com/BurdaPraha/DrupalTwigFood

Useful functions, filters for twig @ Drupal 8

  Sources   Download

GPL-2.0+

28/07 2017

1.0

1.0.0.0 https://github.com/BurdaPraha/DrupalTwigFood

Useful functions, filters for twig @ Drupal 8

  Sources   Download

GPL-2.0+

10/04 2017

dev-dev-refactoring

dev-dev-refactoring https://github.com/BurdaPraha/DrupalTwigFood

Useful functions, filters for twig @ Drupal 8

  Sources   Download

GPL-2.0+