예제 #1
0
 /**
  * Constructor
  *
  * @param string $markup
  * @param array $tokens
  * @param FileSystem $fileSystem
  *
  * @throws \Liquid\LiquidException
  */
 public function __construct($markup, array &$tokens, FileSystem $fileSystem = null)
 {
     $regex = new Regexp('/("[^"]+"|\'[^\']+\')?/');
     if ($regex->match($markup)) {
         $this->templateName = substr($regex->matches[1], 1, strlen($regex->matches[1]) - 2);
     } else {
         throw new LiquidException("Error in tag 'extends' - Valid syntax: extends '[template name]'");
     }
     parent::__construct($markup, $tokens, $fileSystem);
 }
예제 #2
0
 /**
  * Constructor
  *
  * @param string $markup
  * @param array $tokens
  * @param FileSystem $fileSystem
  *
  * @throws \Liquid\LiquidException
  */
 public function __construct($markup, array &$tokens, FileSystem $fileSystem = null)
 {
     $regex = new Regexp('/("[^"]+"|\'[^\']+\')(\\s+(with|for)\\s+(' . Liquid::get('QUOTED_FRAGMENT') . '+))?/');
     if ($regex->match($markup)) {
         $this->templateName = substr($regex->matches[1], 1, strlen($regex->matches[1]) - 2);
         if (isset($regex->matches[1])) {
             $this->collection = isset($regex->matches[3]) ? $regex->matches[3] == "for" : null;
             $this->variable = isset($regex->matches[4]) ? $regex->matches[4] : null;
         }
         $this->extractAttributes($markup);
     } else {
         throw new LiquidException("Error in tag 'include' - Valid syntax: include '[template]' (with|for) [object|collection]");
     }
     parent::__construct($markup, $tokens, $fileSystem);
 }