megumi / wp-twig
Installs: 248
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/megumi/wp-twig
Requires
- php: >=5.3
- twig/twig: ~1.0
This package is not auto-updated.
Last update: 2025-10-26 00:16:42 UTC
README
Integrates Twig template engine to WordPress.
Installation
Create a composer.json in your plugin root or mu-plugins
{
"require": {
"megumi/wp-twig": "*"
}
}
Place the following code into your plugin.
require_once dirname( __FILE__ ) . '/vendor/autoload.php';
Then:
$ composer install
How to use
$twig = new Twig_Environment( new Twig_Loader_String() );
$twig->addExtension( new Megumi\WP\Twig_Extension() );
$content = $twig->render( '{{ name | esc_html }}', array( 'name' => '<strong>' ) );
$this->assertSame( '<strong>', $content );
Twig filter extensions for WordPress
esc_htmlesc_attresc_textareaesc_urlesc_js