1

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?

Mark Ryan Orosa
  • 847
  • 1
  • 6
  • 21
  • 2
    Possible duplicate of [Get data from fs.readFile](https://stackoverflow.com/questions/10058814/get-data-from-fs-readfile) – Matt Oct 31 '17 at 23:05
  • 2
    Hi, I found the answer to the question you link! so thank you! but I would like to maintain this post, simply because it has a better title/description than the other one. It can serve as an alternative. Because I most people who are new to javascript would not even think of `fs.readFile` as search keyword. – Mark Ryan Orosa Nov 01 '17 at 01:47
  • 1
    Great! "Closing" this question as duplicate will leave the question on the site but it will be marked as a duplicate which adds a header near the title linking to the other question(s). – Matt Nov 01 '17 at 02:40

1 Answers1

1

Found the solution in this link, thanks to Matt

const fs = require('fs');
var template = fs.readFileSync('template/emailtemplate.php','utf8');
console.log(template);
Mark Ryan Orosa
  • 847
  • 1
  • 6
  • 21