This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Twig Filter for Symfony 2 - check if asset exists. | |
* | |
* Modified Alain's Tiemblo code: http://stackoverflow.com/a/16906315/2512304 | |
* | |
* Installation: | |
* 1. Add this file to your bundle into src/Acme/DemoBundle/Twig/AssetExistsExtension.php | |
* 2. Update namespace, if your bundle isn't Acme/DemoBundle | |
* 3. Register it in app/config.yml: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Twig Filter for Symfony 2 - truncate HTML string without stripping tags after reach the minimum length of displayed text | |
* Truncates only first-level tags after reach the minimum, so returned text will be >= minimum | |
* Works well with (only?) utf-8 encoding. | |
* | |
* Installation: | |
* 1. Add this file to your bundle into src/Acme/DemoBundle/Twig/TruncateHtmlExtension.php | |
* 2. Update namespace, if your bundle isn't Acme/DemoBundle | |
* 3. Register it in app/config.yml: |
NewerOlder