https://github.com/hfagerlund/strip_anchors
Custom Twig extension for RSS/Atom templates
https://github.com/hfagerlund/strip_anchors
php phpunit symfony symfony4 twig twig-extension twig-filter
Last synced: 3 months ago
JSON representation
Custom Twig extension for RSS/Atom templates
- Host: GitHub
- URL: https://github.com/hfagerlund/strip_anchors
- Owner: hfagerlund
- License: mit
- Created: 2018-09-15T22:53:01.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-09-15T23:05:00.000Z (over 6 years ago)
- Last Synced: 2024-12-27T00:11:34.910Z (5 months ago)
- Topics: php, phpunit, symfony, symfony4, twig, twig-extension, twig-filter
- Language: PHP
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# strip_anchors
[](https://php.net/) [](https://github.com/symfony/symfony/) [](https://github.com/twigphp/Twig/)
The `strip_anchors` [Twig (v.2.5.0)](https://github.com/twigphp/Twig/) filter removes all anchor links (ie. links pointing to different sections of the same page where they are located) from input.
## Sample output:
```html
Features of this Twig Extension
Features of this Twig Extension
```**Please note:** This repository only shows directories and files from a [Symfony 4 skeleton project](https://github.com/hfagerlund/strip_anchors#how-to-use-in-symfony-4) that **need to be added or modified** to enable the 'strip_anchors' Twig extension.
## Usage
Use this Twig filter in an RSS feed template to help transform HTML input into valid RSS 2.0, as shown in the following examples:### Example:
```
{{ item.content|strip_anchors }}
```### Example 2: use in combination with another filter
```
<-- excerpt from rss.xml.twig: -->
```
### How To use in Symfony 4
This repository shows how this custom Twig extension (ie. the `strip_anchors` Twig filter) can be implemented in a Symfony 4 project structure created using [symfony/skeleton](https://symfony.com/doc/current/best_practices/creating-the-project.html).#### Requirements
* [PHP](https://php.net/) (v.7.1.16)
* [Composer](https://getcomposer.org/) (v.1.6.5)
* [symfony/skeleton](https://github.com/symfony/skeleton) (v.4.1.4.2)
* [symfony/twig-bundle](https://github.com/symfony/twig-bundle) (v.4.1.4)
* [symfony/web-server-bundle](https://github.com/symfony/web-server-bundle) (optional: for dev environment)
* [phpunit/phpunit](https://packagist.org/packages/phpunit/phpunit) (v.7.3) OR [symfony/phpunit-bridge](https://github.com/symfony/phpunit-bridge), [symfony/test-pack](https://github.com/symfony/test-pack)(Copyrights for the above remain with their respective owners.)
#### Installation
* Create a new project:
```
$ composer create-project symfony/skeleton my-project
```* Clone this repository (as shown below) and make the corresponding modifications:
```
$ git clone https://github.com/hfagerlund/strip_anchors.git
```## Run (dev) Server:
```
$ php bin/console server:run
```## Run Tests:
From the project **root dir**, run one of the following:### using phpunit/phpunit:
```
$ ./vendor/phpunit/phpunit/phpunit ./tests/
```Or (recommended):
### using symfony/phpunit-bridge
```
$ ./bin/phpunit
```## License
Copyright (c) 2018 Heini Fagerlund. Licensed under the [MIT License](https://github.com/hfagerlund/strip_anchors/blob/master/LICENSE).