Stash::_parse_output PHP Method

_parse_output() private method

Final parsing of the stash variable before output to the template
private _parse_output ( string $value = NULL, string $match = NULL, string $filter = NULL, string $default = NULL ) : string
$value string the string to parse
$match string A regular expression to match against
$filter string A regular expression to filter by
$default string fallback value
return string
    private function _parse_output($value = NULL, $match = NULL, $filter = NULL, $default = NULL)
    {
        // parse tags?
        if (($this->parse_tags || $this->parse_vars || $this->parse_conditionals) && !$this->parse_complete) {
            // do parsing
            $this->EE->TMPL->tagdata = $value;
            $this->_parse_sub_template($this->parse_tags, $this->parse_vars, $this->parse_conditionals, $this->parse_depth);
            $value = $this->EE->TMPL->tagdata;
            unset($this->EE->TMPL->tagdata);
        }
        // regex match
        if ($match !== NULL && $value !== NULL) {
            $is_match = $this->_matches($match, $value);
            if (!$is_match) {
                $value = $default;
            }
        }
        // regex filter
        if ($filter !== NULL && $value !== NULL) {
            preg_match($filter, $value, $found);
            if (isset($found[1])) {
                $value = $found[1];
            }
        }
        // apply string manipulations
        $value = $this->_clean_string($value);
        return $value;
    }