douniwan_0025
2017-10-31 22:50
浏览 106

将HTML文件内容传递给JavaScript变量

I have this template.html that I am going to use as an email template, on loopback/nodejs. in PHP I able to do the following:

ob_start();
include template.php;
$template = ob_get_clean();

Is there anyway possible I can do this with javascript?

图片转代码服务由CSDN问答提供 功能建议

我有这个template.html,我将在loopback / nodejs上用作电子邮件模板。 在PHP中,我能够执行以下操作:

  ob_start(); 
include template.php; 
 $ template = ob_get_clean(); 
   
 
 

有没有可能我可以用javascript做到这一点?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongliulu1122 2017-11-01 01:52
    已采纳

    Found the solution in this link, thanks to Matt

    const fs = require('fs');
    var template = fs.readFileSync('template/emailtemplate.php','utf8');
    console.log(template);
    
    点赞 打赏 评论

相关推荐 更多相似问题