The strip_anchors
Twig (v.2.5.0) filter removes all anchor links (ie. links pointing to different sections of the same page where they are located) from input.
<h2><a href="#features">Features of this Twig Extensiona>h2>
<h2>Features of this Twig Extensionh2>
Please note: This repository only shows directories and files from a Symfony 4 skeleton project that need to be added or modified to enable the 'strip_anchors' Twig extension.
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:
{{ item.content|strip_anchors }}
<-- excerpt from rss.xml.twig: -->
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.
(Copyrights for the above remain with their respective owners.)
$ composer create-project symfony/skeleton my-project
$ git clone https://github.com/hfagerlund/strip_anchors.git
$ php bin/console server:run
From the project root dir, run one of the following:
$ ./vendor/phpunit/phpunit/phpunit ./tests/
Or (recommended):
$ ./bin/phpunit
Copyright (c) 2018 Heini Fagerlund. Licensed under the MIT License.