渲染内容输出

@access public
@param string $content 内容
@param array $vars 模板输出变量
@return mixed
420100
public function show($content, $vars = [])
    {
        // 关闭模板布局
        $this->view->engine->layout(false);

        echo $this->view->fetch($content, $vars, [], [], true);
    }
961785
public function arrayToJson($content = null)
    {
        if ($this->getJsonEncodeArray() && is_array($content)) {
            $this->header('Content-Type: application/json');
            return json_encode($content);
        }

        return $content;
    }
1188529
protected function _parseContent($content) {
        $output = array();
        $matches = array();
        $paramsString = implode('|', $this->_deployParams);
        $pattern = '/:?(?P<paramName>' . $paramsString
            . ')[,:]? [\'"](?P<paramValue>[^\'"]*)[\'"]/';

        if (!preg_match_all($pattern, $content, $matches)) {
            throw new Exception(
                "Could not extract deploy parameters from "
                . self::GENERIC_CONFIG_PATH
            );
        }

        foreach ($this->_deployParams as $p) {
            $indices = array_keys(
                array_filter(
                    $matches['paramName'], function ($pn) use ($p) {
                        return $pn === $p;
                    }
                )
            );
            if (!count($indices)) {
                continue;
            }
            $output[$p] = array_values(array_get_subset($matches['paramValue'], $indices));

            // For now: only treat the server param as array (since it's common for it to be an
            // array, in the case of a multi-server setup)
            if ($p !== 'server') {
                $output[$p] = $output[$p][0];
            }
        }

        // explode server into user and server parts
        if (!empty($output['server'])) {
            $output['server'] = array_map(
                function ($serverConfig) {
                    $bits = explode('@', $serverConfig, 2);
                    return array(
                    'user' => $bits[0],
                    'server' => $bits[1]
                    );
                }, $output['server']
            );
        }

        return $output;
    }
665640
public function coreScriptFilter($content) {

        $attributes = [];

        $attributes["type"] = "text/javascript";

        $innerHTML = null !== $content ? implode("", ["\n", $content, "\n"]) : "";

        return static::coreHTMLElement("script", $innerHTML, $attributes);
    }
1316704
public function display($content, $vars = [], $config = [])
    {
        if ($vars) {
            $this->data = $vars;
        }

        if ($config) {
            $this->config($config);
        }

        $cacheFile = $this->config['cache_path'] . $this->config['cache_prefix'] . md5($content) . '.' . ltrim($this->config['cache_suffix'], '.');

        if (!$this->checkCache($cacheFile)) {
            // 缓存无效 模板编译
            $this->compiler($content, $cacheFile);
        }

        // 读取编译存储
        $this->storage->read($cacheFile, $this->data);
    }
1058618
public static function do($key, $vars=NULL) {
		
		$self = static::getInstance();
		$app  = Application::getInstance();
		
		// load translation strings
		$self->loadStrings();
		
		// search into strings
		if (array_key_exists($key, $self->strings) and $self->strings[$key]) {
			
			$string = $self->strings[$key];
			
		// search into strings of default language
		} else if (is_array($self->defaultStrings) and array_key_exists($key, $self->defaultStrings) and $self->defaultStrings[$key]) {
			
			$app->logWarning('Language string ' . $key . ' is untranslated for current language [' . $self->currentLocale->code . ']');
			$string = $self->defaultStrings[$key];
			
		// return the string constant, as debug info
		} else {
			
			$app->logWarning('Language string ' . $key . ' is untranslated');
			$string = '[' . $key . ']';
			
		}
		
		// vars is optional
		if (!is_null($vars)) {
			
			// force a single string to be the expected array
			if (!is_array($vars)) {
				$vars = array((string)$vars);
			}
			
			// binds of parameters on %s placeholders
			$string = vsprintf($string, $vars);
			
		}
		
		return $string;
		
	}
1065433
public function parseJs($content)
    {
        $matches = $results = array();

        $pattern = '~[^\w]Gplcart\s*\.\s*text\s*\(\s*((?:(?:\'(?:\\\\\'|[^\'])*\'|"(?:\\\\"|[^"])*")(?:\s*\+\s*)?)+)\s*[,\)]~s';
        preg_match_all($pattern, $content, $matches);

        foreach ($matches[1] as $strings) {
            foreach ((array) $strings as $string) {
                $results[] = implode('', preg_split('~(?<!\\\\)[\'"]\s*\+\s*[\'"]~s', substr($string, 1, -1)));
            }
        }

        return $results;
    }
474238
public function handle(string $content = null, array $atts = []): string
    {
        if (!$content) {
            return '';
        }

        $now = new DateTime('now');
        $birthday = new DateTime($content);
        $v = $this->calculate($atts['units'], $now->diff($birthday));

        return sprintf('%d %s', $v, $atts['units']);
    }
873580
public function prepareContent($content)
    {
        if (is_array($content)) {
            $ctt = '';
            foreach ($content as $key=>$ctt_entry) {
                $ctt .= $ctt_entry;
            }
            $content = $ctt;
        }
        return (string) $content;
    }
1364588
public function extractContent($content)
    {
        $regex = '~^('
            . '---'                                  // $matches[1] start separator
            . "){1}[\r\n|\n]*(.*?)[\r\n|\n]+("       // $matches[2] front matter
            . '---'                                  // $matches[3] end separator
            . "){1}[\r\n|\n]*(.*)$~s";               // $matches[4] document content

        return preg_match($regex, $content, $matches) === 1 ? ltrim($matches[4]) : $content;
    }
1161809
public function _present($tag,$content) {
        $name       =   $tag['name'];
        $name       =   $this->autoBuildVar($name);
        $parseStr   =   '<?php if(isset('.$name.')): ?>'.$content.'<?php endif; ?>';
        return $parseStr;
    }
1089875
public function closure($content = null)
    {
        $this->addNewToSequence("open");

        if (!empty($content)) {
            if ($content instanceof TokenSequencer) {
                $this->mergeSequence($content->getSequence());
            } elseif ($content instanceOf Token) {
                $this->addToSequence($content);
            } elseif (is_array($content)) {
                foreach ($content as $subContent) {
                    $this->addMixedContentToSequence($subContent);
                }
            } else {
                $this->val($content);
            }
        }

        $this->addNewToSequence("close");

        return $this;
    }
679080
function variableText( $var, $namespace = "", $attrs = array() )
    {
        $txt = "$";
        if ( $namespace != "" )
            $txt .= "$namespace:";
        $txt .= $var;
        if ( !empty( $attrs ) )
            $txt .= "." . implode( ".", $attrs );
        return $txt;
    }
265193
public function get(string $key, array $vars = [], ?string $language = null): string
	{
		[$file, $string] = $this->parseKey($key);

		if($string === null)
		{
			return $key;
		}

		$string = Arr::get($this->getStrings($language ?? $this->language, $file), $string, $key);

		if(!empty($vars))
		{
			$string = vsprintf($string, $vars);

			if(stripos($string, '</') !== false)
			{
				$string = $this->parseTags($string);
			}
		}

		return $string;
	}
1148053
public function wrapForDataExport($content, $withObjects = false)
    {
        if (!isset($content)) {
            return false;
        }

        if (!$withObjects) {
            return "<?php\n".
            "return " . var_export($content, true) . ";\n".
            "?>";
        } else {
            return "<?php\n".
            "return " . $this->varExport($content) . ";\n".
            "?>";
        }
    }
256729
private function parseInclude(&$content) {
        $regex = $this->getRegex('include');
        $func = function ($template) use (&$func, &$regex, &$content) {
            if (preg_match_all($regex, $template, $matches, PREG_SET_ORDER)) {
                foreach ($matches as $match) {
                    $array = $this->parseAttr($match[0]);
                    $file = $array['file'];
                    unset($array['file']);
                    // 分析模板文件名并读取内容
                    $parseStr = $this->parseTemplateName($file);
                    foreach ($array as $k => $v) {
                        // 以$开头字符串转换成模板变量
                        if (0 === strpos($v, '$')) {
                            $v = $this->get(substr($v, 1));
                        }
                        $parseStr = str_replace('[' . $k . ']', $v, $parseStr);
                    }
                    $content = str_replace($match[0], $parseStr, $content);
                    // 再次对包含文件进行模板分析
                    $func($parseStr);
                }
                unset($matches);
            }
        };
        // 替换模板中的include标签
        $func($content);
        return;
    }
515956
public static function var_dump($var, $varname = '...', $params = array())
    {
        if (!self::isDebug()) {
            return false;
        }

        // var_dump the variable into a buffer and keep the output
        ob_start();
        var_dump($var);
        $output = ob_get_clean();
        $_this  = self::i();

        // neaten the newlines and indents
        $output = preg_replace("/\]\=\>\n(\s+)/m", "] => ", $output);
        //if (!extension_loaded('xdebug')) {
        $output = $_this->_htmlChars($output);
        //}

        $_this->_dumpRenderHtml($output, $varname . '::html', $params);

        return $_this;
    }