Experimental project
This is a sandbox project, which contains experimental code for developer use only.
This module allows admins to create PHP twig filters directly in the administration interface.
Use case
This module provides an easy way for site builders to add additional twig filters without having to write a complete module.
Twig filters added via this module can be used in both theme templates and views rewrites, and everywhere else where twig is used.
These filters exist as configuration entities and therefore can be exported/imported, edited and deleted.
An example: Twig filters allow you to do unit conversion of field values without the need for additional modules. You can add the unit conversion filter via this module and use it in all your templates.
How to use:
Get this sandbox module:
git clone --branch 8.x-1.x http://git.drupal.org/sandbox/FreeAndEasy/2545860.git twigfilter
Step 1: Create Filter
- go to /admin/config/system/twigfilter
- create a new filter by clicking the "Add Twigfilter" button
- name your filter and enter your filter code, save
Step 2: Use Filter
use your filter anywhere (template/views etc) like this:
{{ 'mytext'|twigfilter('my-filter-machinename') }}
Warning: Only give access to this module to trustworthy users, since user entered PHP gets executed.
Project information
- Module categories: Developer Tools
- Created by FreeAndEasy on , updated