Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I just can’t solve the problem with include, I tried different methods, different syntaxes #748

Closed
mrranger opened this issue Oct 25, 2023 · 1 comment

Comments

@mrranger
Copy link

I also tried express-partials, Please help.
ejs: 3.1.9
express: 4.18.2
express-ejs-layouts: 2.5.1
express-partials: 0.3.0
express-session: 1.17.3

TypeError: /home/container/dashboard/views/home/home.ejs:50
48|
49|

50| <%- include ('partials/sidebar') %>
51|
52|
53|

include is not a function

`const express = require('express')
const flash = require('connect-flash');
const session = require('express-session');
const partials = require('express-partials');
const passport = require('passport');
const ejsLint = import('ejs-lint');
var EJS = require('ejs');

const fileUpload = require('express-fileupload');
const config = require('../config/config.json')

const app = express();

const path = require('path');
const http = require('http').Server(app);
const io = require('socket.io')(http);
app.use(partials());

port = config.port;

app.engine('html', EJS.renderFile);

app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, 'views'));
app.use(express.static('dashboard/public'));
app.use(express.static('dashboard/themes'));
app.use(express.urlencoded({ extended: true,limit: '5mb' }));
app.use(fileUpload());

require('./auth/passport')(passport);

// Express session
app.use(
session({
secret: '0tw4cuahvt9m4bt8abaeurhtiac',
resave: true,
saveUninitialized: true
})
);

// Passport middleware
app.use(passport.initialize());
app.use(passport.session());

// Connect flash
app.use(flash());

// Global variables
app.use(function(req, res, next) {
res.locals.success = req.flash('success');
res.locals.error = req.flash('error');
next();
});

app.use('/', require('./routes/home.js'));
app.use('/', require('./routes/settings.js'));
app.use('/', require('./routes/guilds.js'));
app.use('/', require('./routes/support.js'));
app.use('/', require('./routes/plugins.js'));
app.use('/', require('./routes/steamboost.js'));

app.use('/login', require('./routes/login.js'));

http.listen(port)

io.sockets.on('connection', function(sockets){
setInterval(function(){
// Uptime Count
let days = Math.floor(client.uptime / 86400000);
let hours = Math.floor(client.uptime / 3600000) % 24;
let minutes = Math.floor(client.uptime / 60000) % 60;
let seconds = Math.floor(client.uptime / 1000) % 60;

var BOTuptime = `${days}d ${hours}h ${minutes}m ${seconds}s` 

// Emit count to browser 
sockets.emit('uptime',{uptime:BOTuptime}); }, 1000);

})

// Error Pages
app.use(function(req,res){
res.status(404).render('error_pages/404');
});
`

@mde
Copy link
Owner

mde commented Oct 25, 2023

There is something in your application code causing this problem. My suggestion to you is to start with a clean Express app, with only a single EJS page that does nothing but include an EJS file. Then start adding pieces of your app back until you find what is causing the breakage. The EJS include function is incredibly well-tested, and used by millions of people, so it definitely works as described in the docs.

I am closing this issue. If you can create a minimal test that demonstrates an actual problem with EJS, feel free to reopen.

@mde mde closed this as completed Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants