Stash::parse PHP Method

parse() public method

Parse tagdata
public parse ( array $params = [], string $value = NULL ) : string
$params array an array of key => value pairs representing tag parameters
$value string string to parse, defaults to template tagdata
return string
    public function parse($params = array(), $value = NULL)
    {
        // is this method being called directly?
        if (func_num_args() > 0) {
            if (!(isset($this) && get_class($this) == __CLASS__)) {
                return self::_api_static_call(__FUNCTION__, $params, '', '', $value);
            } else {
                return $this->_api_call(__FUNCTION__, $params, '', '', $value);
            }
        }
        // parse="yes"?
        $this->set_parse_params();
        // default parameter values
        $this->EE->TMPL->tagparams['parse_tags'] = $this->EE->TMPL->fetch_param('parse_tags', 'yes');
        $this->EE->TMPL->tagparams['parse_vars'] = $this->EE->TMPL->fetch_param('parse_vars', 'yes');
        $this->EE->TMPL->tagparams['parse_conditionals'] = $this->EE->TMPL->fetch_param('parse_conditionals', 'yes');
        $this->EE->TMPL->tagparams['parse_depth'] = $this->EE->TMPL->fetch_param('parse_depth', 4);
        // postpone tag processing?
        if ($this->process !== 'inline') {
            if ($out = $this->_post_parse(__FUNCTION__)) {
                return $out;
            }
        }
        // re-initialise Stash with the new default params
        $this->init();
        // Unprefix common variables in wrapped tags
        if ($unprefix = $this->EE->TMPL->fetch_param('unprefix')) {
            $this->EE->TMPL->tagdata = $this->_un_prefix($unprefix, $this->EE->TMPL->tagdata);
        }
        // do the business
        $this->_parse_sub_template($this->parse_tags, $this->parse_vars, $this->parse_conditionals, $this->parse_depth);
        // output the parsed template data?
        $output = (bool) preg_match('/1|on|yes|y/i', $this->EE->TMPL->fetch_param('output', 'yes'));
        if ($output) {
            return $this->EE->TMPL->tagdata;
        }
    }