【问题标题】:Cascading Template Use in mustache-express?级联模板在 mustache-express 中使用?
【发布时间】:2021-02-13 21:27:06
【问题描述】:

我的意图是定义一个 page_layout 模板和一个表单模板。在路由处理程序中,我将解析内部(表单)模板并注入比返回更大的布局。

经过几次情节曲折后,我可以使用 response.app 访问我的 mustache 模板引擎并解析视图,但 HTML 被转义了 :(

let router = require('express').Router();
let mustache = require('mustache');
router.get('/plant', function(request,response) {
  response.app.render('plantForm', {pageTitle: "Plant"},function (err, html) {
    response.render ('layout', { pageContent : html});
    });
  });

在我期望内容的地方生成带有转义 html 的外部模板:

             <div class="form-group">
    <label for="plantNameInput">Plant Type</label>

也许我滥用了这项技术?

【问题讨论】:

    标签: node.js express mustache


    【解决方案1】:

    来自 Mustache 文档:

    All variables are HTML escaped by default. If you want to return unescaped HTML, use the triple mustache: {{{name}}}.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-07
      • 1970-01-01
      • 1970-01-01
      • 2014-07-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多