Merge pull request #288 from strapi/fix/ejs

Fix ejs
This commit is contained in:
Aurélien GEORGET 2017-11-01 12:12:32 +01:00 committed by GitHub
commit a6b99cc6a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 30 additions and 5 deletions

View File

@ -340,6 +340,10 @@ It works exactly as before. You need to add `strapi-views` into your app's depen
```json
{
"views": {
"enabled": true,
"map": {
"ejs": "ejs"
},
"viewExt": "ejs",
"debug": true,
"cache": true

View File

@ -10,6 +10,7 @@ const path = require('path');
// Public node modules.
const _ = require('lodash');
const consolidate = require('consolidate');
const views = require('koa-views');
/**
* Public assets hook
@ -69,7 +70,7 @@ module.exports = strapi => {
});
strapi.app.use(
strapi.koaMiddlewares.views(
views(
path.resolve(strapi.config.appPath, strapi.config.paths.views),
opts
)

View File

@ -1,5 +1,5 @@
{
"name": "strapi-views",
"name": "strapi-middleware-views",
"version": "3.0.0-alpha.6.3",
"description": "Views hook to enable server-side rendering for the Strapi framework",
"homepage": "http://strapi.io",
@ -16,6 +16,7 @@
"main": "./lib",
"dependencies": {
"consolidate": "^0.14.5",
"koa-views": "^6.1.1",
"lodash": "^4.17.4"
},
"strapi": {
@ -45,4 +46,4 @@
"npm": ">= 5.3.0"
},
"license": "MIT"
}
}

View File

@ -22,7 +22,8 @@ module.exports = function() {
'./node_modules/strapi-utils',
'./node_modules/strapi-generate*',
'./node_modules/strapi-plugin-*',
'./node_modules/strapi-helper-*'
'./node_modules/strapi-helper-*',
'./node_modules/strapi-middleware-*'
]
}, (err, files) => {
if (err) {

View File

@ -46,6 +46,23 @@ module.exports = function() {
}
);
}),
new Promise((resolve, reject) => {
const cwd = process.cwd();
glob(
'./node_modules/*(strapi-middleware-*)',
{
cwd
},
(err, files) => {
if (err) {
return reject(err);
}
mountMiddlewares.call(this, files, cwd)(resolve, reject);
}
);
}),
new Promise((resolve, reject) => {
const cwd = path.resolve(__dirname, '..', 'middlewares');
@ -124,7 +141,8 @@ const mountMiddlewares = function (files, cwd) {
return (resolve, reject) =>
parallel(
files.map(p => cb => {
const name = p.split('/')[1];
const name = p.replace(/^.\/node_modules\/strapi-middleware-/, './')
.split('/')[1];
this.middleware[name] = {
loaded: false