skrip42/twig-postprocessor-bundle

Add postprocessor to twig

Installs: 28

Dependents: 1

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

Type:symfony-bundle

pkg:composer/skrip42/twig-postprocessor-bundle

v1.0.0 2021-04-06 07:41 UTC

This package is auto-updated.

Last update: 2025-10-06 17:16:09 UTC


README

symphony bundle that adds post-processing functionality to your twig

install

composer require Skrip42/twig-postprocessor-bundle

usage

  • create you own postprocessor that implements Skrip42\Bundle\TwigPostprocessorBundle\PostprocessorInterface
namespace App\Twig;

use Skrip42\Bundle\TwigPostprocessorBundle\PostprocessorInterface;

class YouOwnProcessor implements PostprocessorInterface
{
  /**
   * @params string $content - raw html string
   * @params string $name - template name
   * @params array $context - array of template params
   *
   * @return string - modifyed html string
   */
  public function postProcess(
    string $content,
    string $name,
    array $context
  ): string {
    return someChange($content);
  }
}
  • define you processo as twig postprocessor
  App\Twig\YouOwnProcessor:
    tags:[twig.postprocessor]