sabujdas94/html-template-parser

A secure Twig-based HTML template parser for user-provided templates input.

Installs: 12

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/sabujdas94/html-template-parser

v1.0.3 2024-12-06 07:37 UTC

This package is auto-updated.

Last update: 2026-01-06 10:32:03 UTC


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).