barisusakli 9 years ago
parent f87a8bd016
commit ecd777b659

@ -6,7 +6,7 @@
ajaxify.variables = {}; ajaxify.variables = {};
ajaxify.variables.parse = function() { ajaxify.variables.parse = function() {
var dataEl = $('#content #ajaxify-data'); var dataEl = $('#ajaxify-data');
if (dataEl.length) { if (dataEl.length) {
ajaxify.data = JSON.parse(dataEl.text()); ajaxify.data = JSON.parse(dataEl.text());
} }

@ -47,16 +47,13 @@ module.exports = function(middleware) {
} }
var ajaxifyData = JSON.stringify(options); var ajaxifyData = JSON.stringify(options);
ajaxifyData = ajaxifyData.replace(/<\//g, '<\\/');
render.call(self, template, options, function(err, str) { render.call(self, template, options, function(err, str) {
if (err) { if (err) {
return fn(err); return fn(err);
} }
ajaxifyData = ajaxifyData.replace(/<\//g, '<\\/');
str = str + '<script id="ajaxify-data" type="application/json">' + ajaxifyData + '</script>';
str = (res.locals.postHeader ? res.locals.postHeader : '') + str + (res.locals.preFooter ? res.locals.preFooter : ''); str = (res.locals.postHeader ? res.locals.postHeader : '') + str + (res.locals.preFooter ? res.locals.preFooter : '');
if (res.locals.footer) { if (res.locals.footer) {
@ -75,10 +72,12 @@ module.exports = function(middleware) {
var language = res.locals.config ? res.locals.config.userLang || 'en_GB' : 'en_GB'; var language = res.locals.config ? res.locals.config.userLang || 'en_GB' : 'en_GB';
language = req.query.lang || language; language = req.query.lang || language;
translator.translate(str, language, function(translated) { translator.translate(str, language, function(translated) {
translated = translated + '<script id="ajaxify-data" type="application/json">' + ajaxifyData + '</script>';
fn(err, translated); fn(err, translated);
}); });
}); });
} else { } else {
str = str + '<script id="ajaxify-data" type="application/json">' + ajaxifyData + '</script>';
fn(err, str); fn(err, str);
} }
}); });

Loading…
Cancel
Save