Skip to content

Commit

Permalink
Merge pull request #110 from Financial-Times/removeNinternal
Browse files Browse the repository at this point in the history
ACC-1195 remove n-internal-tool and use n-express #346
  • Loading branch information
asugar13 committed Feb 3, 2022
2 parents dcf62f8 + 6aa483d commit 8f7de61
Show file tree
Hide file tree
Showing 3 changed files with 3,001 additions and 5,638 deletions.
37 changes: 35 additions & 2 deletions demos/app.js
@@ -1,7 +1,11 @@
const express = require('@financial-times/n-internal-tool');
const express = require('@financial-times/n-express');
const chalk = require('chalk');
const errorHighlight = chalk.bold.red;
const highlight = chalk.bold.green;
const { PageKitHandlebars, helpers } = require('@financial-times/dotcom-server-handlebars');
const handlebars = require('handlebars');
const path = require('path');
const fs = require('fs');

const app = module.exports = express({
name: 'public',
Expand All @@ -15,9 +19,38 @@ const app = module.exports = express({
partialsDirectory: process.cwd(),
directory: process.cwd(),
demo: true,
s3o: false
s3o: false,
});

const templateDirectory = path.join(__dirname, '../templates');
fs.readdirSync(templateDirectory).forEach(filename => {
handlebars.registerPartial(
`templates/${filename.substr(0, filename.lastIndexOf('.'))}`,
fs.readFileSync(path.join(templateDirectory, filename), 'utf8')
);
});

const rootDirectory = __dirname;
fs.readdirSync(rootDirectory).forEach(filename => {
if (filename.includes('html')){
handlebars.registerPartial(
`demos/${filename.substr(0, filename.lastIndexOf('.'))}`,
fs.readFileSync(path.join(rootDirectory, filename), 'utf8')
);
}
});

app.set('views', __dirname);
app.set('view engine', '.html');

app.engine('.html', new PageKitHandlebars({
cache: false,
handlebars,
helpers: {
...helpers
}
}).engine);

app.get('/', (req, res) => {
res.render('demo', {
title: 'Test App',
Expand Down

0 comments on commit 8f7de61

Please sign in to comment.