载入一个模板作为邮件内容

@param string $template
@param array  $param
@param array  $config

@return Mailer
187276
public function view($template, $param = [], $config = [])
    {
        $view = Think::instance('Think\View');
        if ($param) {
            foreach ($param as $key => $value) {
                // 处理变量中包含有对元数据嵌入的变量
                $this->embedImage($key, $value, $param);
                $view->assign($key, $value);
            }
        }
        $content = $view->fetch($template);

        return $this->html($content);
    }
1008741
public static function message($template_body = null, $options = array()) {
        $message = new Message();
        MailHelper::setMessage($message);

        if ($template_body) {
            $template = Module::template($template_body);
            $message->body($template->compile($options));
        }

        return $message;
    }
1154533
public static function sendNewMessage($email, $templateId, $templateParams = [])
    {
        $email = explode(',', $email);
        foreach ((array) $email as $singleEmail) {
            $message = new Message;
            $message->attributes = [
                'email' => trim($singleEmail),
                'template_id' => $templateId,
                'packed_json_template_params' => Json::encode($templateParams),
                'status' => Message::STATUS_NEW,
            ];
            if ($message->save()) {
                static::runTask(
                    [
                        realpath(Yii::getAlias('@app') . '/yii'),
                        'emails/send',
                        $message->id,
                    ],
                    Module::DEFERRED_TASK_GROUP_MESSAGE_SEND
                );
            }
        }
    }
765291
public function render($template, array $data = array())
    {
        $data = array_merge($data, $this->website->helpers());

        $data['config'] = $this->website;

        $renderer = $this->website->renderer();

        return $renderer->render($template, $data);
    }
1138071
public static function template($template, $parameter = array(), $status = 200, $headers = array())
    {
        View::setTemplate($template, $parameter);

        return new Response('', $status, $headers);
    }
272080
protected function fetch($template = '', $vars = [], $replace = [], $config = [])
    {
        // 页面标题
        $this->assign('site_title', $this->site_title);
        
        return $this->view->fetch($template, $vars, $replace, $config);
    }
1139984
public function render($template=null, array $params=[]) {
		if($template === null)
			$template = $this->template;
		$params = array_merge($this->params, $params);

		return static::renderFile($template, $params);
	}
186264
public function renderViewPrint( $template, $models, $config = [] ) {

		return $this->renderViewGeneric( $template, $models, CoreGlobal::TPL_VIEW_PRINT, $config );
	}
559235
public function htmlTemplate($template, $data=[]) {
		$data['message'] = $this;
		$res = $this->buildTemplate($template, $data);
		return $this->html($res);
	}
674536
public function textTemplate($template, $data=[]) {
		$data['message'] = $this;
		$res = $this->buildTemplate($template, $data);
		return $this->text($res);
	}
912134
public static function translateMail(MailInterface $template, $locale, TranslatorInterface $translator = null)
    {
        if (null === $template->getTranslationDomain()) {
            $template = $template->getTranslation($locale);
        } elseif (null !== $translator) {
            static::injectTranslatorValues($translator, $template);
        }

        return $template;
    }
617450
public static function create($template = 'Response') {
	    $return = null;

	    switch ($template) {
            case 'Discovery':
                $return = new AlexaResponse(
                    new Response(
                        new Event(
                            new Header(),
                            new Payload()
                        )
                    )
                );
            break;

            case 'StateReport':
                $return = new AlexaResponse(
                    new Response(
                        new Event(
                            new Header(),
                            new Payload(),
                            new Endpoint()
                        ),
	                    new Context()
                    )
                );
            break;

            case 'Response':
                $return = new AlexaResponse(
                    new Response(
                        new Event(
                            new Header(),
                            new Payload(),
                            new Endpoint()
                        ),
	                    new Context()
                    )
                );
            break;

		    case 'Authorization':
			    $return = new AlexaResponse(
				    new Response(
					    new Event(
						    new Header(),
						    new Payload()
					    )
				    )
			    );
		    break;

		    case 'Error':
			    $return = new AlexaResponse(
				    new Response(
					    new Event(
						    new Header(),
						    new Payload()
					    )
				    )
			    );
		    break;

            default:
                throw new InvalidArgumentException('Unsupported AlexaResponse template: ' . $template);
            break;
        }

        return $return;
	}
700130
public function template($template, $data = array(), $options = '')
    {
        $this->template = array($template, $data, $options);
        $template = new Template(Base::getInstance());
        $this->loaderHooks($template,'pre_template',$class='',$method_name='',$data=array());
        return $template;
    }
163730
public function mail($template, $data = array(), &$css = array())
    {
        $this->twig->addFunction(new \Twig_SimpleFunction('css', function ($file) use (&$css) {
            $css[] = $file;
        }));
        $template = $this->twig->loadTemplate($template);
        return $template->render($data);
    }
65663
public function fetch($template, $vars = [], $config = [])
    {
        if ($vars) {
            $this->data = $vars;
        }

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

        $template = $this->parseTemplateFile($template);

        if ($template) {

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

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

            // 页面缓存
            ob_start();
            ob_implicit_flush(0);

            // 读取编译存储
            $this->storage->read($cacheFile, $this->data);

            // 获取并清空缓存
            $content = ob_get_clean();

            echo $content;
        }
    }
89562
public function setTemplateParam( $param, $value )
	{
		if ( !isset( $param ) || empty( $param ) || !isset( $value ) )
		{
			trigger_error( "The parameter \$param or \$value can't be empty." );
			return false;
		}
		$this->params_template[$param] = $value;
	}
420372
protected function renderDefaultTemplate($template, $params=[]) {
		if(!file_exists($template)) {
			$template = $this->solveTemplatePath($orig = $template);
			if(!file_exists($template))
				throw new \Exception('The template file "'.$orig.'" could not be found.');
		}

		extract($params);

		ob_start();
		include($template);
		return ob_get_clean();
	}