https://github.com/dcsg/stringy-template
Stringy and StringTemplate together in one class for simplicity
https://github.com/dcsg/stringy-template
php php-library string-manipulation string-template
Last synced: about 1 year ago
JSON representation
Stringy and StringTemplate together in one class for simplicity
- Host: GitHub
- URL: https://github.com/dcsg/stringy-template
- Owner: dcsg
- License: mit
- Created: 2019-03-10T08:21:56.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-03-21T12:38:32.000Z (about 4 years ago)
- Last Synced: 2025-02-05T18:30:50.564Z (about 1 year ago)
- Topics: php, php-library, string-manipulation, string-template
- Language: PHP
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 2
- 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
Awesome Lists containing this project
README
# StringyTemplate
[](https://php.net/)
[](https://packagist.org/packages/dcsg/stringy-template)
[](https://packagist.org/packages/dcsg/stringy-template)
[](https://travis-ci.org/dcsg/stringy-template)
[](https://github.styleci.io/repos/174796258)
[](https://insight.symfony.com/projects/e339c7bf-3d04-4e29-91e1-58a459525848)
[](https://sonarcloud.io/dashboard?id=stringy-template)
[](https://sonarcloud.io/dashboard?id=stringy-template)
[](https://sonarcloud.io/dashboard?id=stringy-template)
[](https://sonarcloud.io/dashboard?id=stringy-template)
[](https://sonarcloud.io/dashboard?id=stringy-template)
[](https://packagist.org/packages/dcsg/stringy-template)
This Library provides a unified `S` Class that "glues" two amazing libraries. It integrates the [Stringy][link-stringy] library created by [Daniel St. Jules][link-stringy-author] and the [StringTemplate][link-string-template] Library create by [Nicolò Martini][link-string-template-author].
The **Stringy** Library is a **string manipulation** library, while the **String Template** is an engine to render string templates.
This Library was created because in my projects I've been using both libraries and always ended up in having them integrated into a single class to make it's usage simpler.
## Install
Via Composer
```bash
$ composer require dcsg/stringy-template
```
## Usage
For the full list of features of Stringy see it's [documentation][link-stringy], for more details on the String Template you can also check their [documentation][link-string-template].
```php
echo S::render(
'Hello, my name is {firstName} {lastName}.',
['firstName' => 'Daniel', 'lastName' => 'Gomes']
);
// "Hello, my name is Daniel Gomes."
// Using conversion specifications from `sprintf`
echo S::render(
'I have {num%.1f} {fruit}.',
['num' => 1.5345, 'fruit' => 'oranges']
);
// "I have 1.5 oranges."
echo S::join(['one', 'two', 'three'], ', ');
// "one, two, three"
```
## Change log
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Testing
```bash
$ composer test
```
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE OF CONDUCT](CODE_OF_CONDUCT.md) for details.
## Security
If you discover any security related issues, please email hi@dcsg.me instead of using the issue tracker.
## Credits
- [Daniel Gomes][link-author]
- [All Contributors][link-contributors]
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
[link-author]: https://github.com/dcsg
[link-contributors]: ../../contributors
[link-stringy]: https://github.com/danielstjules/Stringy
[link-stringy-author]: https://github.com/danielstjules
[link-string-template]: https://github.com/nicmart/StringTemplate
[link-string-template-author]: https://github.com/nicmart