sabujdas94 / html-template-parser
A secure Twig-based HTML template parser for user-provided templates input.
v1.0.3
2024-12-06 07:37 UTC
Requires
- php: >=7.4
- twig/twig: ^3.0
Requires (Dev)
- phpunit/phpunit: ^9.6
README
You can find usage examples in the examples/
directory.
Basic Example
require 'path-to-your-package/vendor/autoload.php'; use SecureTemplateParser\SecureTemplateParser; $parser = new SecureTemplateParser(); $template = <<<EOT Hi {{ user.name }} {% if user.age > 18 %} You're eligible for adult benefits. {% else %} You're still a minor. {% endif %} EOT; $data = [ 'user' => [ 'name' => 'John Doe', 'age' => 25, ], ]; echo $parser->render($template, $data); ## License This package is open-source software licensed under the [MIT License](LICENSE).