javascript - NodeJS include header and footer without EJS -


i hoping may able assist me nodejs. iv started developing site using nodejs.

the problem:

im looking way send documents a header, content, footer style reduces repeating code each section.

i have public folder setup can include js, css , common files etc...

self.app.use(express.static(__dirname + '/public')); 

this works, im unsure how implement simple way join file content. every source iv looked @ online suggests "correct" way via package called ejs templates.

so im looking similar implementation in ejs:

<header>     <% include ../partials/header %> </header>  <footer>     <% include ../partials/footer %> </footer> 

however, service im hosting on not support ejs, possible this?

self.routes['/'] = function(req, res) {             res.setheader('content-type', 'text/html');             res.send(self.cache_get('header.html')+self.cache_get('index.html')+self.cache_get('footer.html') );         }; 

is there simple way separate header, content , footer make simpler develop website dynamic content?

while write own js this, @ current level don't recommend (other learning , experimental purposes). why node powerful, because don't have reinvent wheel time. noted using openshift, , cannot use modules. this incorrect.

this link explains how use npm openshift. extremely silly node.js hosting service not allow package integration. briefly explain how works, install packages in local environment using --save flag. update local package.json file details dependencies , versions. when push repo host, looks @ file, , takes care of dependency installation you.

on note, if going continue using node.js, should have read package management. https://docs.npmjs.com/how-npm-works/packages


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -