-
Notifications
You must be signed in to change notification settings - Fork 6
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
express running, modified template cannot be rendered rightly #22
Comments
Can you give me a reliable way of reproducing the error ? There is indeed probably a caching problem. |
Here is how to recreate the issue, he is using Locomotive, so perhaps that is the easiest way, from the command line run: npm install locomotive -g
lcm create hello
cd hello
npm install
npm install jinjs Then, change /config/environments/all.js to: var express = require('express'); module.exports = function() {
this.set('views', __dirname + '/../../app/views');
this.set('view engine', 'jinjs');
this.set('view options', {
layout: false
});
this.use(express.logger());
this.use(express.bodyParser());
this.use(this.router);
this.use(express.static(__dirname + '/../../public'));
}; Then, add 'base.html.jinjs' to '/app/views' with this in the file: <!DOCTYPE html>
<html>
<head>
<title>Hello</title>
</head>
<body>
{% block content %}
{% endblock %}
</body>
</html> Then, add 'main.html.jinjs' to '/app/views/pages' with this in the file: {% extends "base.html.jinjs" %}
{% block content %}
<h1>{{ title }}</h1>
{% endblock %} Now, start the app from the command line with: lcm server Then, open your browser to 'http://127.0.0.1:3000'. The first load will work, then refresh the page, after 2-5 refreshes, you will see the error described above. Below is the offending line, deps is the undefined property in environment.js: _this.deps[__filename][path] = true; |
I have the same problem and for now I have solved with this solution, but I'm not certainly is the best solution. The solution is this page Zizzamia/zizzamia.com@688bfa7#diff-2 . Let me know if you find a good way. :-) |
I had the same issue, and I can confirm Zizzamia's fix for environment.js seems to resolve it: // Solved the problem for now, but I'm certainly not the best solution.
try {
_this.deps[__filename][path] = true;
return _this.getTemplate(path);
} catch (err){
return _this.getTemplate(path);
} Importing 'pwilang' didn't seem to make a difference as far as I can tell. Just needs the above fix to jinjs/lib/environment.js around line 160. |
Nice... I'm not alone in this issue :-D |
I'm also having the same problem and Zizzamia's patch corrects it. Thanks! |
when express server is running, I modify my template. Then access the page, the errors occurred:
500 TypeError: Cannot set property '/home/jock/apps/huodongtong/app/views/layout/form_layout.html' of undefined
at /home/jock/node_modules/jinjs/lib/environment.js:159:38
at eval at (/home/jock/node_modules/jinjs/lib/environment.js:165:14)
at Object.render (eval at (/home/jock/node_modules/jinjs/lib/environment.js:165:14))
at ServerResponse._render (/home/jock/node_modules/express/lib/view.js:425:21)
at ServerResponse.render (/home/jock/node_modules/express/lib/view.js:318:17)
at Controller.render (/home/jock/node_modules/locomotive/lib/locomotive/controller.js:98:14)
But, when I restart the server, all is right again.
what's the problem? Jinjs cached something or not?
Another question, can Jinjs can persist the compiled templates into physical files?
The text was updated successfully, but these errors were encountered: