Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/BurdaPraha/DrupalTwigFood
Useful functions, filters for twig @ Drupal 8
https://github.com/BurdaPraha/DrupalTwigFood
czech-republic drupal drupal-8 filter prague region svg twig twig-extension
Last synced: 4 months ago
JSON representation
Useful functions, filters for twig @ Drupal 8
- Host: GitHub
- URL: https://github.com/BurdaPraha/DrupalTwigFood
- Owner: BurdaPraha
- License: gpl-2.0
- Created: 2017-01-19T16:25:10.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2022-02-20T17:51:33.000Z (over 2 years ago)
- Last Synced: 2024-07-20T13:07:38.769Z (4 months ago)
- Topics: czech-republic, drupal, drupal-8, filter, prague, region, svg, twig, twig-extension
- Language: PHP
- Homepage: http://www.burda.cz
- Size: 29.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DrupalTwigFood
Useful functions, filters for twig @ Drupal 8## Instalation
Recomended using is via Composer:
`composer require burdapraha/drupal_twig_food`
... and install module "Burda Twig Food" in administration (domain.tld/admin/modules)## Documentation
The best documentation is easy examples, right? :-)
### 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.#### - load_block($id)
you can call block by name anywhere in template: ```{{ load_block('machine_name') }}```#### - load_region($id)
this function offers print all block of the region anywhere you need: ```{{ load_region('machine_name') }}```#### - load_main_node($returnId = true)
solving problem with getting node id from anywhere template when you need it ```{{ load_main_node() }}```#### - load_gallery_prev($currentGalleryId, $thumbnailStyle = 'thumbnail')
array with previous media gallery: ```{{ load_gallery_prev(2) }}```#### - load_gallery_next($currentGalleryId, $thumbnailStyle = 'thumbnail')
array with next media media: ```{{ load_gallery_next(1) }}```#### - load_gallery_thumbs($galleryId, $thumbnailStyle = 'thumbnail')
array with images from gallery: ```{{ load_gallery_thumbs(5) }}```------
### Filters
#### - naked_field
return rendered field, for example from view, without developers suggestions (``````), without HTML tags like `your_filed`. 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 %}`#### - 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.