cable8mm / stub-template
The package is not a template engine, but you can use it like one to create stub files when needed.
Requires
- php: ^8.1
- twig/twig: ^3.0
Requires (Dev)
- laravel/pint: ^1.20
- phpunit/phpunit: ^9.0|^10.0|^11.0
Suggests
- laravel/pint: Provide a easy way to fit coding style
This package is auto-updated.
Last update: 2025-02-11 13:59:13 UTC
README
The package is not a template engine, but you can use it like one to create stub files when needed.
It needs to be used with Twig template syntax.
Installation
You can install the package via composer:
composer require cable8mm/stub-template
Usage
$stub = Stub::of(__DIR__.'/stubs/sample.stub', [ 'title' => 'Home Page', 'colors' => ['red', 'blue', 'green'], ] )->render()
or
$stub = Stub::of('stubs/sample.stub', [ 'title' => 'Home Page', 'colors' => ['red', 'blue', 'green'], ], __DIR__ )->render()
stubs/sample.stub :
{{ title }} - <?php echo date('Y-m-d') ?> <h1>Home</h1> <p>Welcome to the home page, list of colors:</p> <ul> {% for color in colors %} <li>{{ color }}</li> {% endfor %} </ul>
Then,
Home Page - <?php echo date('Y-m-d') ?> <h1>Home</h1> <p>Welcome to the home page, list of colors:</p> <ul> <li>red</li> <li>blue</li> <li>green</li> </ul>
It make sure that php codes have NOT been executed.
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email cable8mm@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
PHP Package Boilerplate
This package was generated using the PHP Package Boilerplate by Beyond Code.