Skip to main content

render_template_response

Function render_template_response 

Source
pub fn render_template_response(
    view: &View,
    template: &str,
    vars: Option<HashMap<String, Value>>,
) -> Result<Response<Body>, ViewError>
Expand description

渲染模板文件为 HTML Response(兜底场景,自由函数版本)

对齐 PHP $this->fetch('template') + Response::create($content, 'html')。 便捷函数,无需创建 ViewFallback 实例。

§参数

  • view:视图实例
  • template:模板名
  • vars:模板变量(可选)

§返回

Ok(Response):HTTP 200,Content-Type: text/html; charset=utf-8 Err(ViewError):模板未找到 / 渲染失败