Tom M
Tom M

Reputation: 2904

PHP include equivalent for markup in Nodejs

So I need the PHP include functionality for markup in NodeJS/Express. I searched around for a bit and stumbled across this question: Nodejs Include Other Views?

I need about the same thing but I don't really want to include/learn a full template engine like jade though and basically, I just need this specific functionality. Is there a cooler method than just read the split files by using fs.read and returning a concatenated string for express to deliver?

I'd preferably call the files in the html with some kind of placeholder than building them together in my JS. Also, if there is an easy way to do this with 'vanilla' nodejs functionality, I'd choose this over some module since I'm still learning.

Thanks in advance!

PHP

<?php include('header.php'); ?>
<body>
    //content
</body>
<?php include('footer.php'); ?>

Upvotes: 1

Views: 508

Answers (1)

Ariel Borochov
Ariel Borochov

Reputation: 24

Using ejs should bring it close to php. Its in the node stack and should be close. Here is the link to the github https://github.com/tj/ejs/blob/master/Readme.md

Upvotes: 0

Related Questions