Integrates Twig template engine to WordPress.
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
$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 );
esc_html
esc_attr
esc_textarea
esc_url
esc_js