Closed ghost closed 11 years ago
Thanks. I've been seeing this too and I'm having trouble tracking it down. Do the tests work for you? (Do npm install --dev
and npm test
to try).
@RandomEtc The tests of include
fail too.
․․․․․․․․․․․․․․․․․․․․․․․․․․
✖ 7 of 26 tests failed:
1) app GET /with-include-here should include and interpolate locals.ejs when rendering with-include.ejs:
AssertionError: expected response code of 200 'OK', but got 500 'Internal Server Error'
at Object.Assertion.status (/opt/node.js/lib/node_modules/should/lib/should.js:627:10)
at /home/boris/ejs-locals/test/test.partials.js:272:27
at IncomingMessage.Request.end (/home/boris/ejs-locals/test/support/http.js:91:9)
at IncomingMessage.EventEmitter.emit (events.js:123:20)
at IncomingMessage._emitEnd (http.js:366:10)
at HTTPParser.parserOnMessageComplete [as onMessageComplete] (http.js:149:23)
at Socket.socketOnData [as ondata] (http.js:1366:20)
at TCP.onread (net.js:403:27)
2) app GET /with-include-there should include and interpolate locals.ejs when rendering with-include.ejs:
AssertionError: expected response code of 200 'OK', but got 500 'Internal Server Error'
at Object.Assertion.status (/opt/node.js/lib/node_modules/should/lib/should.js:627:10)
at /home/boris/ejs-locals/test/test.partials.js:284:27
at IncomingMessage.Request.end (/home/boris/ejs-locals/test/support/http.js:91:9)
at IncomingMessage.EventEmitter.emit (events.js:123:20)
at IncomingMessage._emitEnd (http.js:366:10)
at HTTPParser.parserOnMessageComplete [as onMessageComplete] (http.js:149:23)
at Socket.socketOnData [as ondata] (http.js:1366:20)
at TCP.onread (net.js:403:27)
3) app GET /with-include-chain should include and interpolate include-chain-2.ejs when rendering with-include-chain.ejs:
AssertionError: expected response code of 200 'OK', but got 500 'Internal Server Error'
at Object.Assertion.status (/opt/node.js/lib/node_modules/should/lib/should.js:627:10)
at /home/boris/ejs-locals/test/test.partials.js:296:27
at IncomingMessage.Request.end (/home/boris/ejs-locals/test/support/http.js:91:9)
at IncomingMessage.EventEmitter.emit (events.js:123:20)
at IncomingMessage._emitEnd (http.js:366:10)
at HTTPParser.parserOnMessageComplete [as onMessageComplete] (http.js:149:23)
at Socket.socketOnData [as ondata] (http.js:1366:20)
at TCP.onread (net.js:403:27)
4) app GET /with-include-chain-subfolder should include and interpolate parent-include-chain.ejs when rendering with-include-chain-subfolder.ejs:
AssertionError: expected response code of 200 'OK', but got 500 'Internal Server Error'
at Object.Assertion.status (/opt/node.js/lib/node_modules/should/lib/should.js:627:10)
at /home/boris/ejs-locals/test/test.partials.js:308:27
at IncomingMessage.Request.end (/home/boris/ejs-locals/test/support/http.js:91:9)
at IncomingMessage.EventEmitter.emit (events.js:123:20)
at IncomingMessage._emitEnd (http.js:366:10)
at HTTPParser.parserOnMessageComplete [as onMessageComplete] (http.js:149:23)
at Socket.socketOnData [as ondata] (http.js:1366:20)
at TCP.onread (net.js:403:27)
5) app GET /with-two-includes should include both files and interpolate the same data:
AssertionError: expected response code of 200 'OK', but got 500 'Internal Server Error'
at Object.Assertion.status (/opt/node.js/lib/node_modules/should/lib/should.js:627:10)
at /home/boris/ejs-locals/test/test.partials.js:320:27
at IncomingMessage.Request.end (/home/boris/ejs-locals/test/support/http.js:91:9)
at IncomingMessage.EventEmitter.emit (events.js:123:20)
at IncomingMessage._emitEnd (http.js:366:10)
at HTTPParser.parserOnMessageComplete [as onMessageComplete] (http.js:149:23)
at Socket.socketOnData [as ondata] (http.js:1366:20)
at TCP.onread (net.js:403:27)
6) app GET /with-absolute-include should include locals.ejs and interpolate the data correctly:
AssertionError: expected response code of 200 'OK', but got 500 'Internal Server Error'
at Object.Assertion.status (/opt/node.js/lib/node_modules/should/lib/should.js:627:10)
at /home/boris/ejs-locals/test/test.partials.js:332:27
at IncomingMessage.Request.end (/home/boris/ejs-locals/test/support/http.js:91:9)
at IncomingMessage.EventEmitter.emit (events.js:123:20)
at IncomingMessage._emitEnd (http.js:366:10)
at HTTPParser.parserOnMessageComplete [as onMessageComplete] (http.js:149:23)
at Socket.socketOnData [as ondata] (http.js:1366:20)
at TCP.onread (net.js:403:27)
7) app GET /with-absolute-sub-include should include subfolder/sublocals.ejs and include subfolder/subitem.ejs correctly:
AssertionError: expected response code of 200 'OK', but got 500 'Internal Server Error'
at Object.Assertion.status (/opt/node.js/lib/node_modules/should/lib/should.js:627:10)
at /home/boris/ejs-locals/test/test.partials.js:344:27
at IncomingMessage.Request.end (/home/boris/ejs-locals/test/support/http.js:91:9)
at IncomingMessage.EventEmitter.emit (events.js:123:20)
at IncomingMessage._emitEnd (http.js:366:10)
at HTTPParser.parserOnMessageComplete [as onMessageComplete] (http.js:149:23)
at Socket.socketOnData [as ondata] (http.js:1366:20)
at TCP.onread (net.js:403:27)
OK this is helpful - thanks! Can you let me know what OS, OS version and node version you're using?
@RandomEtc I am using Ubuntu 12.10 beta 3
and uname -a
outputs
Linux tales 3.5.0-15-generic #23-Ubuntu SMP Mon Sep 24 20:37:06 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
And my node version is v0.8.11
.
I'm experiencing the same problem on my system, the output of uname -a
for me is:
Linux barnes-workstation 3.5.0-17-generic #27-Ubuntu SMP Fri Oct 5 01:35:26 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
Node Version: v0.8.11
and Express Version: 3.0.0rc5
console.log(include.toString());
outputs function () { [native code] }
If I use <%- locals.include("flash"); %>
or <%- include flash %>
it appears to work, as opposed to what's expected from the documentation.
Weird but good to know, thanks for the sleuthing. I'll take a look later today for sure. As Express 3 settles down this is to be expected I guess. I'll also try to tackle the include and partial paths and make sure the caching is sane on those as well.
Didn't get as far as I like with this, sorry! Next chance I'll have to fix it is probably Sunday.
got the same error..
mac os 10.8.2
For those following along with this - unfortunately EJS specifies its own include
now!
The syntax is slightly different. Where you did <%-include('foo')%>
with ejs-locals
you should be able to do <% include foo %>
with EJS itself.
I'll remove include
from this package and publish a new version shortly. The version number will be a major increment. In the meantime I'll publish a patch fix specifying the last version of EJS that didn't have include
support.
Sorry for the delay tracking this down!
OK, this is "fixed" for the short-term in ejs-locals
0.2.6 which requires ejs
0.7 now. I will shortly push ejs-locals
1.0 which removes its own include
so you can use the EJS one.
<%- include('header.ejs') %> //ignores header file
<%- include header %> //Show down error
SyntaxError: Unexpected token '/' in C:\ExpressJS\RestRouteInfo\vDone1\views\register.ejs while compiling ejs
If the above error is not helpful, you may want to try EJS-Lint:
https://github.com/RyanZim/EJS-Lint
Or, if you meant to create an async function, pass async: true
as an option.
at new Function (
I have exactly same problem as @SV96, nothing from docs or the internet works.
Same problem as @Liniik and @SV96! I have replaced my template engine from:
app.engine('html', require('ejs').renderFile);
to:
app.engine('html', require('ejs-locals'));
Now, the include function, work successful for me!
To anyone facing that problem, the new syntax Is <%- include('partials/header') %>.
To anyone facing that problem, the new syntax Is <%- include('partials/header') %>.
Did you read my comment? I said that nothing from docs or the internet works so neither does your syntax.
I got it finally worked with <% include foot %>
.
My template engine was defined by express generator: app.set('view engine', 'ejs');
I totally forgot to mention it, so sorry for that.
sooo ... anyone get it right ?
You can use
<%- include('partial/head'); %>
<p>homepage</p>
<%- include('partial/foot'); %>
This works perfectly fine. **Don't forget to put the "semicolon" at the end of brackets. My template engine was defined by: app.set('view engine', 'ejs');
<%- include('partial/head'); %>
works for me,thanks
The syntax
doesn't work here and throws the error:
while the
is fine.