aldaflux/fine-diff-bundle

FineDiff Symfony5 Bundle implementation

Installs: 5 712

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 2

Type:symfony-bundle

v2.2.1 2022-04-20 09:08 UTC

This package is auto-updated.

Last update: 2024-10-20 15:03:42 UTC


README

Original fine diff library:

Installation

Add to composer

Run in command line:

$ composer require AlDaFlux/fine-diff-bundle

Or add with hand to composer.json:

    "require": {
        "AlDaFlux/fine-diff-bundle": "~1.10"
    }

Register the bundle

Add the app

<?php
    // app/AppKernel.php
    
    public function registerBundles()
	{
		$bundles = array(
			// ...
			new AlDaFlux\FineDiffBundle\AlDaFluxPHPFineDiffBundle(),
		);
	}

Configure

Optional. You can change the default granularity.

# app/config/config.yml

AlDaFlux_fine_diff:
    default_granularity: character # This is the default granularity. Alternatives: 'word', 'sentence' and 'paragraph'

Usage

There are two twig function:

  • renderDiff(): compare two strings
  • renderHtmlTextDiff(): compare two strings which contain HTML tags. Remove tags with strip_tags before compare strings
{{ renderDiff(oldValue, newValue) }}
{{ renderDiff(oldValue, newValue, 'word') }}

{{ renderHtmlTextDiff(oldValue, newValue) }}
{{ renderHtmlTextDiff(oldValue, newValue, 'sentence') }}