alto / twig-code-highlight
Highlight source code in Twig templates with a tag or filter.
Fund package maintenance!
Requires
- php: ^8.4
- alto/code-highlight: ^1.0
- twig/twig: ^3.28
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.94
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^12.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Highlight source code directly from Twig templates with a tag or filter powered by ALTO Code Highlight.
Use the block tag for source written in a template or the filter for source provided by your application:
{% code_highlight 'php' %}
<?php echo 'Hello, Alto!';
{% endcode_highlight %}
{{ source|code_highlight('javascript') }}
Installation
composer require alto/twig-code-highlight
The package requires PHP 8.4 or later, ALTO Code Highlight 1.x, and Twig 3.28 or later.
Documentation
Contributing
Contributions of all kinds are welcome. Visit the project on GitHub to report a bug, suggest a feature, or open a pull request.
Before submitting code, run:
# Runs PHP CS Fixer, PHPStan, and PHPUnit
composer qa
Changes to public behavior should include tests and documentation.
Support
ALTO Twig Code Highlight is open source and independently maintained by Simon André. If it is useful to your work, you can support its continued development through GitHub Sponsors.
Sharing the package or starring it on GitHub also helps.
License
ALTO Twig Code Highlight is released by ALTO PHP under the MIT License.