Last active
          August 9, 2022 19:04 
        
      - 
      
 - 
        
Save zburgermeiszter/afb9cb14b9a6f3f023e1 to your computer and use it in GitHub Desktop.  
    TWIG Base64 extension for Symfony
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| namespace Vendor\Bundle\Twig; | |
| /* | |
| services.yml: | |
| twig.base64: | |
| class: Vendor\Bundle\Twig\Base64 | |
| tags : | |
| - { name: twig.extension } | |
| */ | |
| class Base64 extends \Twig_Extension { | |
| public function getFilters(){ | |
| return array( | |
| new \Twig_SimpleFilter('base64_encode', 'base64_encode'), | |
| new \Twig_SimpleFilter('base64_decode', 'base64_decode') | |
| ); | |
| } | |
| public function getName(){ | |
| return "base64"; | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
With more recents versions of Twig: