Download the PHP package heimrichhannot/truncate-html without Composer
On this page you can find all versions of the php package heimrichhannot/truncate-html. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download heimrichhannot/truncate-html
More information about heimrichhannot/truncate-html
Files in heimrichhannot/truncate-html
Package truncate-html
Short Description Handle truncate action on HTML strings
License MIT
Informations about the package truncate-html
urodoz/truncateHTML
PHP library to handle truncate action on HTML strings
Features
- Truncates an HTML string keeping consistency on open/close tags
- No external dependencies.
- PSR-4 compatible.
- Compatible with PHP >= 5.3.3 and
- Integrations for Symfony2 and Twig.
Installation
You can install urodoz/truncateHTML through Composer:
Usage
Truncate an HTML string:
Integrations
Symfony2
TruncateHTML contains a Symfony2 bundle and service definition that allow you to use it as a service in your Symfony2 application.
The code resides in the Urodoz\Truncate\Bridge\Symfony
namespace and you only need to add the bundle class to your AppKernel.php
:
You can now use the urodoz_truncate
service everywhere in your application, for example, in your controller:
Twig
If you use the Symfony2 framework with Twig you can use the Twig filter truncateHTML
in your templates after you have setup Symfony2 integrations (see above).
If you use Twig outside of the Symfony2 framework you first need to add the extension to your environment:
You can find more information about registering extensions in the Twig documentation.
Author
License
The MIT License (MIT)
Copyright (c) 2014 Albert Lacarta
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.