skrip42/twig-postprocessor-bundle

Add postprocessor to twig

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

This package is auto-updated.

Last update: 2024-11-06 15:16:52 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]