Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.61 KB | None | 0 0
  1. <?php
  2. namespace Typeflex;
  3.  
  4. /**
  5.  * This disgusting hack is caused by Liquid being overly strict with their render method signature.
  6.  */
  7. if (PHP_MAJOR_VERSION >= 7) {
  8.     set_error_handler(function ($errno, $errstr, $file) {
  9.         return strpos($file, 'includes'.DIRECTORY_SEPARATOR.'classes'.DIRECTORY_SEPARATOR.'Liquid.php') !== false &&
  10.         strpos($errstr, 'Declaration of') === 0;
  11.     }, E_WARNING);
  12. }
  13.  
  14. /**
  15.  * Class that extends Liquid and sets up sensible defaults.
  16.  */
  17. class Liquid extends \Liquid\Template
  18. {
  19.     private function initialise() {
  20.  
  21.         \Liquid\Liquid::set('INCLUDE_SUFFIX', 'liquid');
  22.         \Liquid\Liquid::set('INCLUDE_PREFIX', '');
  23.  
  24.         \Liquid\Liquid::set('INCLUDE_ALLOW_EXT', false);
  25.         \Liquid\Liquid::set('ESCAPE_BY_DEFAULT', false);
  26.        
  27.         \Liquid\Liquid::set('PAGINATION_CONTEXT_KEY', 'pagination_page');
  28.  
  29.         $this->registerTag('include', '\Typeflex\Sieve\TagInclude');
  30.     }
  31.  
  32.     public function __construct ($path = null) {
  33.  
  34.         $this->initialise();
  35.         $this->registerFilter(new \Typeflex\HtmlFilter());
  36.         $this->registerTag('form', 'LiquidTagForm');
  37.         //$this->registerTag('form', new \Typeflex\CustomTags());
  38.         $this->setCache(new \Liquid\Cache\Local());
  39.  
  40.         parent::__construct($path);
  41.     }
  42.  
  43.     public function render(Sieve\Container $assigns, $filters = null, array $registers = array())
  44.     {
  45.         $assigns = (array)$assigns;
  46.         return parent::render($assigns, $filters, $registers);
  47.     }
  48. }
  49.  
  50. class LiquidTagForm extends \Liquid\Tag\AbstractBlock
  51. {
  52.     public function render($context) {
  53.        
  54.         echo $context;
  55.         exit;
  56.        
  57.         $str = '<form action="./" method="post"></form>';
  58.        
  59.         return $str;
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement