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

use jinjs with express, errors occured #21

Closed
ghost opened this issue Feb 14, 2012 · 5 comments
Closed

use jinjs with express, errors occured #21

ghost opened this issue Feb 14, 2012 · 5 comments

Comments

@ghost
Copy link

ghost commented Feb 14, 2012

500 TypeError: object is not a function
at ExpressEnvironment.CALL_NON_FUNCTION (native)
at ExpressEnvironment.getTemplateFromString (/usr/local/lib/node_modules/jinjs/lib/express.js:34:82)
at Object.compile (/usr/local/lib/node_modules/jinjs/lib/express.js:64:45)
at Function.compile (/usr/local/lib/node_modules/locomotive/node_modules/express/lib/view.js:68:33)
at ServerResponse._render (/usr/local/lib/node_modules/locomotive/node_modules/express/lib/view.js:417:18)
at ServerResponse.render (/usr/local/lib/node_modules/locomotive/node_modules/express/lib/view.js:318:17)

who can explain that?

Jinjs: 0.3.5
Express: 2.5.6
Node: 0.6.7
OS: Debian

@ceymard
Copy link
Member

ceymard commented Feb 14, 2012

Can you give me a way to reproduce the error so that I can look into it ?

@ghost
Copy link
Author

ghost commented Feb 14, 2012

I modify the lib/express.js at the line 34 as res = expressEnvironment.superclass.prototype.getTemplateFromString.call(this, str, ctx);

the original is : res = ExpressEnvironment.superclass.prototype.getTemplateFromString.call.call(this, this, str, ctx);

the same as lib/express.js line 23: return ExpressEnvironment.superclass.prototype.trackFile.call(this, path);

all is OK!!

The way is following your guide:
#npm install jinjs

and my express config is that:
var jinja = require('jinjs');
app.register('.html', jinja);
app.set('views', __dirname + '/../../app/views');
app.set('view engine', 'html');
this.set('view options', {layout: false});

and I DON'T use precompiling with pwilang, because if use, it issued some other bug as followings:

layout.html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{% block title %}{{PAGE_TITLE}} | {{ SITE_TITLE }}{% endblock %}</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
....
<style type="text/css">
#page {
margin-top: 0;
}
</style>
</head>
<body>
<div id="page" class="container ">
<div id="header">
{% block header %}
{% include "../common/header.html" %}
{% endblock %}
</div>
</div>
</body>
</html>

and the css style part in the ultimate rendered page will be like this:
.....

<style type="text/css">
<div id="page">{
margin-top: 0;
}
</style>

....

when I disable pre-compiling, the problem gone!

@ceymard
Copy link
Member

ceymard commented Feb 14, 2012

I'm going to remove the pwilang precompilation entirely, as it obviously only is confusing...

@ceymard
Copy link
Member

ceymard commented Feb 14, 2012

Latest version should work.

@ghost
Copy link
Author

ghost commented Feb 14, 2012

OK, thanks. All work now.

This issue can be closed

@ceymard ceymard closed this as completed Feb 14, 2012
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