https://github.com/cable8mm/stub-template
The package is not a template engine, but you can use it like one to create stub files when needed.
https://github.com/cable8mm/stub-template
Last synced: 4 months ago
JSON representation
The package is not a template engine, but you can use it like one to create stub files when needed.
- Host: GitHub
- URL: https://github.com/cable8mm/stub-template
- Owner: cable8mm
- License: mit
- Created: 2025-02-09T16:25:54.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-11T13:58:15.000Z (over 1 year ago)
- Last Synced: 2025-06-29T16:03:51.980Z (12 months ago)
- Language: PHP
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
# Stub Template


[](https://packagist.org/packages/cable8mm/stub-template)
[](https://packagist.org/packages/cable8mm/stub-template)
[](https://packagist.org/packages/cable8mm/stub-template)
[](https://github.com/cable8mm/stub-template/stargazers)
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](https://twig.symfony.com/doc/3.x/templates.html).
## Installation
You can install the package via composer:
```bash
composer require cable8mm/stub-template
```
## Usage
```php
$stub = Stub::of(__DIR__.'/stubs/sample.stub',
[
'title' => 'Home Page',
'colors' => ['red', 'blue', 'green'],
]
)->render()
```
or
```php
$stub = Stub::of('stubs/sample.stub',
[
'title' => 'Home Page',
'colors' => ['red', 'blue', 'green'],
],
__DIR__
)->render()
```
stubs/sample.stub :
```twig filename="stubs/sample.stub"
{{ title }} -
Home
Welcome to the home page, list of colors:
- {{ color }}
{% for color in colors %}
{% endfor %}
```
Then,
```html
Home Page -
Home
Welcome to the home page, list of colors:
- red
- blue
- green
```
It make sure that php codes have **NOT** been executed.
### Testing
```bash
composer test
```
### Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
### Security
If you discover any security related issues, please email instead of using the issue tracker.
## Credits
- [Samgu Lee](https://github.com/cable8mm)
- [All Contributors](../../contributors)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
## PHP Package Boilerplate
This package was generated using the [PHP Package Boilerplate](https://laravelpackageboilerplate.com) by [Beyond Code](http://beyondco.de/).