UNPKG

html-pages

Version:

Simple development HTTP Server for file serving and directory listing made by a Designer. Use it for hacking your HTML/JavaScript/CSS files but not for deploying your final site.

17 lines (12 loc) 444 B
// Native const path = require('path'); // Packages const fs = require('fs-promise'); const Handlebars = require('handlebars'); module.exports = (page) => { const pageToLoad = page === undefined ? 'index' : page + '.hbs'; let viewContent = false; const viewPath = path.normalize(path.join(__dirname, '/../views/' + pageToLoad + '.hbs')); viewContent = fs.readFileSync(viewPath, 'utf8'); return Handlebars.compile(viewContent); };