/** * Constructor * * @param string $markup */ public function __construct($markup) { $this->markup = $markup; $quotedFragmentRegexp = new Regexp('/\\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_FILTER_ARGUMENT') . ')/'); $quotedFragmentRegexp->match($markup); $this->name = isset($quotedFragmentRegexp->matches[1]) ? $quotedFragmentRegexp->matches[1] : null; 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]); $this->filters[] = array($filtername, $matches); } } else { $this->filters = array(); } }