Skip to content

jaem3l/TwigEvalExtension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TwigEvalExtension

One of the goals of Twig is to limit the amount of logic in your templates. Unfortunately you won't be able to do all sorts of stuff you can do with PHP. To regain that power you can use TwigEvalExtension. Just write your php code inside an eval() template function and it gets passed to PHP's eval and you will get the result.

Installation

You can install the extension by using composer require.

Example Usage

Using the eval function:

{{ eval('echo 1+1;') }}

Using the eval tag:

{% eval %}
    echo file_get_contents("/var/log/system.log");
{% endeval %}

Tests

Just run

$ vendor/bin/phpunit tests/EvalExtensionTest.php

No pesky phpunit.xml needed.

Contribution

Please don't.

Known Issues

It's eval in your templates. What could possibly go wrong?!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages