/** * Constructor * * @param string $markup * @param array $tokens * @param FileSystem $fileSystem * * @throws \Liquid\LiquidException */ public function __construct($markup, array &$tokens, FileSystem $fileSystem = null) { $syntaxRegexp = new Regexp('/(\\w+)\\s*=\\s*(' . Liquid::get('QUOTED_FRAGMENT') . '+)/'); $filterSeperatorRegexp = new Regexp('/' . Liquid::get('FILTER_SEPARATOR') . '\\s*(.*)/'); $filterSplitRegexp = new Regexp('/' . Liquid::get('FILTER_SEPARATOR') . '/'); $filterNameRegexp = new Regexp('/\\s*(\\w+)/'); $filterArgumentRegexp = new Regexp('/(?:' . Liquid::get('FILTER_ARGUMENT_SEPARATOR') . '|' . Liquid::get('ARGUMENT_SEPARATOR') . ')\\s*(' . Liquid::get('QUOTED_FRAGMENT') . ')/'); $this->filters = array(); if ($filterSeperatorRegexp->match($markup)) { $filters = $filterSplitRegexp->split($filterSeperatorRegexp->matches[1]); foreach ($filters as $filter) { $filterNameRegexp->match($filter); $filtername = $filterNameRegexp->matches[1]; $filterArgumentRegexp->matchAll($filter); $matches = Liquid::arrayFlatten($filterArgumentRegexp->matches[1]); array_push($this->filters, array($filtername, $matches)); } } if ($syntaxRegexp->match($markup)) { $this->to = $syntaxRegexp->matches[1]; $this->from = $syntaxRegexp->matches[2]; } else { throw new LiquidException("Syntax Error in 'assign' - Valid syntax: assign [var] = [source]"); } }