twig-drupal-filters
Version:
Drupal's Twig filters, implemented for Twig.js
46 lines (33 loc) • 1.21 kB
Markdown
# Twig.js Drupal Extensions
[](https://greenkeeper.io/)
[](https://travis-ci.org/kalamuna/twig-drupal-filters)
Twig.js implementations of Drupal's Twig functions and filters. Most of these are just stubbed creations from [John Albin's work in KSS-Node](https://github.com/kss-node/kss-node/blob/master/builder/base/twig/extend-drupal8/drupal8-extensions.js).
## Usage
``` javascript
var Twig = require('twig')
var twigDrupal = require('twig-drupal-filters')
// Add the filters to Drupal.
twigDrupal(Twig);
```
``` twig
{{ 'Hello World!'|clean_id }}
```
### Filters
A comprehensive list of the filters is [available here](http://www.opin.ca/en/article/twig-filters-drupal-8).
- t
- trans
- placeholder
- without
- clean_class
- clean_id
- render
- path
- url
- format_date
- drupal_escape
- safe_join
### Functions
- link
- active_theme*
- attach_library*
_*These are dummy functions that don't do anything except keep Twig.js compilation from breaking when these Drupal-specific functions are used in Drupal Twig templates._