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

content is not defined #52

Open
ilyesbrh opened this issue Jul 25, 2021 · 0 comments
Open

content is not defined #52

ilyesbrh opened this issue Jul 25, 2021 · 0 comments

Comments

@ilyesbrh
Copy link

ilyesbrh commented Jul 25, 2021

when i try to pass locals to both layout and template i get a strange error

layout_content is not defined at eval (eval at compile (C:\Users\Farmy\Documents\github\laboratory_website\bakcend\express\node_modules\ejs-layout\lib\ejs.js:577:12), <anonymous>:10:8) at returnedFn (C:\Users\Farmy\Documents\github\laboratory_website\bakcend\express\node_modules\ejs-layout\lib\ejs.js:606:17) at Object.exports.renderFile (C:\Users\Farmy\Documents\github\laboratory_website\bakcend\express\node_modules\ejs-layout\lib\ejs.js:417:31) at C:\Users\Farmy\Documents\github\laboratory_website\bakcend\express\node_modules\ejs-layout\lib\ejs.js:1103:28 at Object.exports.renderFile (C:\Users\Farmy\Documents\github\laboratory_website\bakcend\express\node_modules\ejs-layout\lib\ejs.js:423:10) at View.exports.main [as engine] (C:\Users\Farmy\Documents\github\laboratory_website\bakcend\express\node_modules\ejs-layout\lib\ejs.js:1100:11)

my code:

router:js:
res.render('index', { currentRoute: 'test', layout_content: req.ejs.layout_content, page_content: custom_content });

layout.ejs:
<title><% layout_content.title %></title> <%- defineContent('body') %>

main.ejs:
<p><% layout_content.text%></p>

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

1 participant