/** * Constructor * * @param string $markup * @return LiquidVariable */ public function __construct($markup) { $this->markup = $markup; $quoted_fragment_regexp = new LiquidRegexp('/\\s*(' . LIQUID_QUOTED_FRAGMENT . ')/'); $filter_seperator_regexp = new LiquidRegexp('/' . LIQUID_FILTER_SEPARATOR . '\\s*(.*)/'); $filter_split_regexp = new LiquidRegexp('/' . LIQUID_FILTER_SEPARATOR . '/'); $filter_name_regexp = new LiquidRegexp('/\\s*(\\w+)/'); $filter_argument_regexp = new LiquidRegexp('/(?:' . LIQUID_FILTER_ARGUMENT_SEPARATOR . '|' . LIQUID_ARGUMENT_SEPARATOR . ')\\s*(' . LIQUID_QUOTED_FRAGMENT . ')/'); $quoted_fragment_regexp->match($markup); //$this->_name = $quoted_fragment_regexp->matches[1]; $this->_name = isset($quoted_fragment_regexp->matches[1]) ? $quoted_fragment_regexp->matches[1] : null; // harry if ($filter_seperator_regexp->match($markup)) { $filters = $filter_split_regexp->split($filter_seperator_regexp->matches[1]); foreach ($filters as $filter) { $filter_name_regexp->match($filter); $filtername = $filter_name_regexp->matches[1]; $filter_argument_regexp->match_all($filter); //$matches = array_flatten($filter_argument_regexp->matches[1]); $matches = Liquid::array_flatten($filter_argument_regexp->matches[1]); $this->filters[] = array($filtername, $matches); } } else { $this->filters = array(); } }
/** * Constructor * * @param string $markup * @param array $tokens * @param LiquidFileSystem $file_system * @return AssignLiquidTag */ public function __construct($markup, &$tokens, &$file_system) { $syntax_regexp = new LiquidRegexp('/(\\w+)\\s*=\\s*(' . LIQUID_QUOTED_FRAGMENT . '+)/'); $filter_seperator_regexp = new LiquidRegexp('/' . LIQUID_FILTER_SEPARATOR . '\\s*(.*)/'); $filter_split_regexp = new LiquidRegexp('/' . LIQUID_FILTER_SEPARATOR . '/'); $filter_name_regexp = new LiquidRegexp('/\\s*(\\w+)/'); $filter_argument_regexp = new LiquidRegexp('/(?:' . LIQUID_FILTER_ARGUMENT_SEPARATOR . '|' . LIQUID_ARGUMENT_SEPARATOR . ')\\s*(' . LIQUID_QUOTED_FRAGMENT . ')/'); $this->filters = array(); if ($filter_seperator_regexp->match($markup)) { $filters = $filter_split_regexp->split($filter_seperator_regexp->matches[1]); foreach ($filters as $filter) { $filter_name_regexp->match($filter); $filtername = $filter_name_regexp->matches[1]; $filter_argument_regexp->match_all($filter); $matches = Liquid::array_flatten($filter_argument_regexp->matches[1]); array_push($this->filters, array($filtername, $matches)); } } if ($syntax_regexp->match($markup)) { $this->_to = $syntax_regexp->matches[1]; $this->_from = $syntax_regexp->matches[2]; } else { throw new LiquidException("Syntax Error in 'assign' - Valid syntax: assign [var] = [source]"); } }
/** * Constructor * * @param string $markup * @return LiquidVariable */ function LiquidVariable($markup) { $this->markup = $markup; $quoted_fragment_regexp = new LiquidRegexp('/\\s*(' . LIQUID_QUOTED_FRAGMENT . ')/'); $filter_seperator_regexp = new LiquidRegexp('/' . LIQUID_FILTER_SEPERATOR . '\\s*(.*)/'); $filter_split_regexp = new LiquidRegexp('/' . LIQUID_FILTER_SEPERATOR . '/'); $filter_name_regexp = new LiquidRegexp('/\\s*(\\w+)/'); $filter_argument_regexp = new LiquidRegexp('/(?:' . LIQUID_FILTER_ARGUMENT_SEPERATOR . '|' . LIQUID_ARGUMENT_SPERATOR . ')\\s*(' . LIQUID_QUOTED_FRAGMENT . ')/'); $quoted_fragment_regexp->match($markup); $this->name = $quoted_fragment_regexp->matches[1]; if ($filter_seperator_regexp->match($markup)) { $filters = $filter_split_regexp->split($filter_seperator_regexp->matches[1]); foreach ($filters as $filter) { $filter_name_regexp->match($filter); $filtername = $filter_name_regexp->matches[1]; $filter_argument_regexp->match_all($filter); $matches = array_flatten($filter_argument_regexp->matches[1]); $this->filters[] = array($filtername, $matches); } } else { $this->filters = array(); } }