Git Product home page Git Product logo

strip_anchors's Introduction

strip_anchors

Minimum PHP Version Minimum Symfony Version Minimum Twig Version

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.

Sample output:

<!-- BEFORE applying filter: -->
<h2><a href="#features">Features of this Twig Extension</a></h2>

<!-- AFTER applying `strip_anchors` filter: -->
<h2>Features of this Twig Extension</h2>

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.

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: -->

<content:encoded>
   <![CDATA[
    {{ item.content|md2html|strip_anchors }}
   ]]>
</content:encoded>

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.

Requirements

(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.

strip_anchors's People

Contributors

hfagerlund avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.