模板渲染
@param string $tpl 模板
@param array $data
@return string
@throws HttpException
439940
protected function display($tpl, $data = [], $auto_set_tpl_dir = true)
    {
        if ($auto_set_tpl_dir) {
            $dir = substr(get_called_class(), 4);
            $dir = str_replace(['Controllers', 'Controller'], '', $dir);
            $dir = str_replace('\\', '/', $dir);
            $dir = str_replace('//', '/', $dir);
            $dir = strtolower(trim($dir, '/'));
            return $this->response->tpl($dir . '/' . $tpl, $data);
        } else {
            return $this->response->tpl($tpl, $data);
        }

    }
516904
protected function _post($data) {
		$ch = curl_init();
		curl_setopt_array($ch, array(
			CURLOPT_URL            => static::ENDPOINT,
			CURLOPT_POST           => true,
			CURLOPT_POSTFIELDS     => json_encode($data),
			CURLOPT_HEADER         => false,
			CURLOPT_RETURNTRANSFER => true,
			CURLOPT_SSL_VERIFYPEER => true,
			CURLOPT_SSL_VERIFYHOST => 2,
			CURLOPT_FOLLOWLOCATION => false,
			CURLOPT_HTTPHEADER => array('Content-Type: application/json')
		));

		$response = curl_exec($ch);
		curl_close($ch);

		if ($response === false) {
			throw new Exception('Failed to contact BrowserID verification service');
		}

		$decodedResponse = json_decode($response);
		if (!$decodedResponse) {
			throw new Exception('Response is not valid JSON');
		}

		return $decodedResponse;
	}
683304
protected function _process($tpl) {
        $this->_display_html = '';
        \extract($this->_vars);

        \ob_start();
        include "{$this->_template_dir}/{$tpl}";
        $this->_display_html .= \ob_get_contents();
        \ob_end_clean();

        $display_html = $this->_display_html;
        $this->_clear();
        return $display_html;
    }
763877
public function chatroomCreate($data = array()) {
        try{
            if(empty($data))
                throw new Exception('要加入群的用户 Id 不能为空');
            $params = array();
            foreach($data as $key=>$val) {
                $k = 'chatroom['.$key.']';
                $params["$k"] = $val;
            }
            $ret = $this->curl('/chatroom/create', $params);
            if(empty($ret))
                throw new Exception('请求失败');
            return $ret;
        }catch (Exception $e) {
            print_r($e->getMessage());
        }
    }
496289
public function display($tpl, $tpl_vars = null) {
        if (!($this->_response instanceof \Swoole\Http\Response)) {
            throw new \Exception(200118);
        }


        $old_value = ini_set('xdebug.cli_color', 0);
        $html = $this->render($tpl, $tpl_vars);
        $this->_response->end($html);
        $old_value === false || ini_set('xdebug.cli_color', $old_value);
        return true;
    }
495588
function (data, callback) {
            var html = '';
            var self = this;
            var fn = self.fn;
            callback = callback || function (error, ret) {
                html = ret;
            };
            var name = self.config.name;
            if (!name && fn.TPL_NAME) {
                name = fn.TPL_NAME;
            }
            var scope = new Scope(data), buffer = new LinkedBuffer(callback).head;
            renderTpl({
                name: name,
                fn: fn,
                session: {},
                root: self
            }, scope, buffer);
            return html;
        }
583908
public function display($tpl, $data = array())
    {
        if ($this->isRending) {
            throw new RenderException('Display is called.');
        }

        $this->assign($data);

        echo $this->render($tpl, $data);

        return true;
    }
1297234
public function display($tpl = '')
    {
        if (Container::get('request')->isCli()) {
            throw new ResponseException('cannot render template in CLI mode');
        }

        if ('' === $tpl) {
            $tpl = Container::get('route')->getController() . '/'
            . Container::get('route')->getAction();
        }

        $this->viewPath = $this->tplDir . $tpl . '.html';
        if (!Helper::isFile($this->viewPath)) {
            throw new NotFoundException('Template is not existed.');
        }

        unset($tpl);
        ob_start();
        extract($this->data, EXTR_OVERWRITE);
        include $this->viewPath;
        $buffer = ob_get_contents();
        ob_get_clean();
        $output = Helper::comment() . preg_replace('|</body>.*?</html>|is', '', $buffer, -1, $count) . Container::get('trace')->showTrace();
        if ($count > 0) {
            $output .= '</body></html>';
        }

        echo $output;
    }
506706
protected function loadTpl($tpl)
    {
        $this->tplBase = $this->request->args('tplBase') ? $this->request->args('tplBase') : dirname($tpl);
        $content = file_get_contents($tpl);
        $this->prepareTpl($content);
        return json_decode($content, true);
    }
633983
public function send($data)
    {
        $token = $this->grantToken();
        $newData = $data;
        foreach($token as $k=>$v) {
            $newData[$k] = $v;
        }

        //必填 消息发送类型,其值为unicast,listcast,broadcast,groupcast或customizedcast
        if(!isset($data['type'])) {
            throw new Exception('need param: type');
        }

        // 可选 当type=customizedcast时,开发者填写自己的alias,友盟根据alias进行反查找,得到对应的device_token。多个alias时用英文逗号分,不能超过50个。
        if(isset($data['alias']) && !empty($data['alias'])) {
            if(is_array($data['alias'])) {
                $newData['alias'] = implode(',', $data['alias']);
            } else {
                $newData['alias'] = $data['alias'];
            }
        }

        // 必填 消息类型，值为notification或者message
        if(!isset($data['payload']['display_type'])) {
            $newData['payload']['display_type'] = 'notification';
        }

        // 必填 通知栏提示文字。但实际没有用，todo确认
        if(!isset($data['payload']['body']['ticker'])) {
            $newData['payload']['body']['ticker'] = $data['payload']['body']['title'];
        }

        //可选 消息描述。用于友盟推送web管理后台，便于查看。
        if(!isset($data['description'])) {
            $newData['description'] = $data['payload']['body']['title'];
        }
        
        $defaultTrueParams = array(
            // 通知到达设备后的提醒方式
            'play_vibrate', // 可选 收到通知是否震动,默认为"true".注意，"true/false"为字符串
            'play_lights',  // 可选 收到通知是否闪灯,默认为"true"
            'play_sound',   // 可选 收到通知是否发出声音,默认为"true"
        );

        foreach($defaultTrueParams as $one) {
            if(isset($data['payload']['body'][$one]) && ($data['payload']['body'][$one] == false || $data['payload']['body'][$one] == 'false')) {
                $newData['payload']['body'][$one] = 'false';
            }
        }

        $http = new \HTTPRequest($this->conf['api_uri_prefix'] . 'api/send', HTTP_METH_POST);
        $http->setBody(json_encode($newData));
        $http->send();
        $body = $http->getResponseBody();
        if($http->getResponseCode() != 200) {
            throw new Exception($body);
        }
        $tmp = json_decode($body, true);

        if(!isset($tmp['ret']) || $tmp['ret'] != 'SUCCESS') {
            throw new Exception($body);
        }
        return true;
    }
226611
public function post ($data)
		{
			$this->_options[ CURLOPT_POST ] = 1;
			$this->_options[ CURLOPT_POSTFIELDS ] = is_array($data) ? http_build_query($data) : $data;

			return $this->send();
		}
80609
private function httpBuildQuery(array $data): string
    {
        $queryString = http_build_query($data, '', '&');

        return $this->postProcessHttpQueryString($queryString, $data);
    }
1181029
public static function display($tpl, $variablesDefinitions = NULL, $indent = NULL) {
    $html = self::get($tpl, $variablesDefinitions, $indent);
    print $html;
  }
1205733
public function display($tpl = null)
	{
		$state  = $this->get('State');
		$items  = $this->get('Items');
		$parent = $this->get('Parent');

		$app = JFactory::getApplication();

		// Check for errors.
		if (count($errors = $this->get('Errors')))
		{
			$app->enqueueMessage($errors, 'error');

			return false;
		}

		if ($items === false)
		{
			$app->enqueueMessage(JText::_('JGLOBAL_CATEGORY_NOT_FOUND'), 'error');

			return false;
		}

		if ($parent == false)
		{
			$app->enqueueMessage(JText::_('JGLOBAL_CATEGORY_NOT_FOUND'), 'error');

			return false;
		}

		$params = &$state->params;

		$items = array($parent->id => $items);

		// Escape strings for HTML output
		$this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'), ENT_COMPAT, 'UTF-8');

		$this->maxLevelcat = $params->get('maxLevelcat', -1) < 0 ? PHP_INT_MAX : $params->get('maxLevelcat', PHP_INT_MAX);
		$this->params      = &$params;
		$this->parent      = &$parent;
		$this->items       = &$items;

		$this->prepareDocument();

		return parent::display($tpl);
	}
1226079
public function sendTemplate(User $toUser, $tplId, array $data, $url = '')
    {
        $this->logger->debug('send template message', [
            'user' => $toUser['id'],
            'tplId' => $tplId,
            'url' => $url,
            'data' => $data,
        ]);

        if (!$this->isVerifiedService()) {
            return [
                'code' => -1,
                'message' => '没有开通该服务',
            ];
        }

        if (!$tplId) {
            return [
                'code' => -2,
                'message' => '缺少模板编号',
            ];
        }

        if (!$toUser['isValid'] || !$toUser['wechatOpenId']) {
            return [
                'code' => -3,
                'message' => '用户未关注',
            ];
        }

        $api = $this->createApiService();
        $api->sendTemplate([
            'touser' => $toUser['wechatOpenId'],
            'template_id' => $tplId,
            'url' => $url,
            'data' => $data,
        ]);

        return $api->getResult();
    }
381843
public function loadTemplate($tpl, $data = array(), $viewData = true)
    {
        $viewData && $data = $data + $this->viewData;
        if(substr_count($tpl,'::') ) {
            return view($tpl, $data);
        }
        return view('hstcms::manage.'.$tpl, $data);
    }
84277
public function renderTemplate($tpl, array $render) {
    $registry = new \Drutiny\Registry();
    $loader = new \Twig_Loader_Filesystem($registry->templateDirs());
    $twig = new \Twig_Environment($loader, array(
      'cache' => sys_get_temp_dir() . '/drutiny/cache',
      'auto_reload' => TRUE,
      // 'debug' => true,
    ));
    // $twig->addExtension(new \Twig_Extension_Debug());

    // Filter to sort arrays by a property.
    $twig->addFilter(new \Twig_SimpleFilter('psort', function (array $array, array $args = []) {
        $property = reset($args);

        usort($array, function ($a, $b) use ($property) {
          if ($a[$property] == $b[$property]) {
            return 0;
          }
          $index = [$a[$property], $b[$property]];
          sort($index);
          return $index[0] == $a[$property] ? 1 : -1;
        });

        return $array;
    },
    ['is_variadic' => true]));

    $template = $twig->load($tpl . '.' . $this->getFormat() . '.twig');
    $contents = $template->render($render);
    return $contents;
  }