Answer the question
In order to leave comments, you need to log in
Dzhang-like templating engine or how to fix swig?
Good afternoon.
Upgrading node.js from 0.7.9 to 0.8.6 did not go unnoticed — in addition to a couple of deprecated functions, express had an error when configuring the django-like templating engine swig :
TypeError: Object function app(req, res){ app.handle(req , res); } has no method 'register'
app.register('.html', swig);<br>
app.set('views', VIEWS_PATH);<br>
app.set('view engine', 'html');<br>
Answer the question
In order to leave comments, you need to log in
So. The source of the problems is express.js updated from 2.5.0 to 3.0.0.
The migration guide is here - github.com/visionmedia/express/wiki/Migrating-from-2.x-to-3.x , but not everything is so simple: the register function, which had problems, was replaced with an engine that works somewhat otherwise.
Here is what a long search and digging in the code gave:
the author of swig himself decided to switch from express.js to consolidate.js. However, you can still make swig work under the third express by adding to swig/index.js:
exports.__express = function (path, options, fn) {
options = options || {};
try {
options.filename = path;
var tmpl = exports.compileFile(_.last(path.split('/')));
fn(null, tmpl.render(options));
} catch (err) {
fn(err);
}
};
app.register('.html', swig); // для express v.2
app.engine('.html', swig.__express); // для express v.3
this entry is enough for me to work phpmyadmin from a folder inside the site:
location /myadmin {
index index.php;
}
For example something like this:
location /samle {
root /var/www/test2/sample;
rewrite ^sample/(.*)$ /$1 break;
}
With this config "No input file specified."
location /sample {
index index.html index.php;
#try_files $uri $uri/ /index.php?$args;
alias /var/www/test2/sample;
rewrite ^sample/(.*)$ /$1 break;
location ~ \.php$ {
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_index index.php;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
}
location /sample {
root /var/www/test2/sample;
rewrite ^sample/(.*)$ /$1 break;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question