Is there way to file (css/js) call based on specific page condition in EJS, Or any flag using from router or condition based on URL in EJS file
Note: Below code is working fine when calling /editor
page but it will break if go other page because of undefined 'isEditorPage
' variable . I think this practice is bad idea So I am searching for perfect way for this situation
It is a common header - ejs file
<head>
<link rel="stylesheet" href="common.css">
<%if (isEditorPage) { %>
<link rel="stylesheet" href="../css/admin/editor.css">
<% } %>
</head>
Express router
router.get('/editor', function(req, res){
let isEditorPage = true;
Blog.find({}, function(err, blog){
res.render('admin/blog', {isEditorPage} );
});
});