【问题标题】:Passing dynamical information using ejs and html使用 ejs 和 html 传递动态信息
【发布时间】:2017-05-23 04:41:57
【问题描述】:

所以我试图将一些变量(数字)数据传递给电子邮件模板。我正在尝试像这样使用 ejs:

var compiled = ejs.compile(fs.readFileSync(path_to_file, 'utf-8'));

const mailOptions = {
        from: app.get('senderMail'),
        // Atention***********************
        // Let this hardcoded otherwise it will send email to all db
        to: email,
        subject: sujbjet,
        text: 'Hello Word',
        html: compiled({number : number})
    };

在我的 html 代码中,我试图呈现如下内容:

<span> <=% number %> </span>

但我没有得到“数字”的实际值。它呈现如下内容:

我有什么遗漏吗?

提前致谢

【问题讨论】:

    标签: html node.js ejs


    【解决方案1】:

    您以错误的方式打开了output 标签。反等号和百分号:

    <span> <%= number %> </span>
    

    【讨论】:

    • 不敢相信!谢谢
    猜你喜欢
    • 1970-01-01
    • 2017-10-06
    • 1970-01-01
    • 2016-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-15
    相关资源
    最近更新 更多