diff --git a/public/src/templates.js b/public/src/templates.js
index 34b8784be6..b3ea78105c 100644
--- a/public/src/templates.js
+++ b/public/src/templates.js
@@ -5,7 +5,8 @@
var config = {},
templates,
fs = null,
- available_templates = [];
+ available_templates = [],
+ parsed_variables = {};
module.exports = templates = {};
@@ -153,8 +154,8 @@
(function() {
jQuery.get(API_URL + api_url, function(data) {
- if(!data) {
- window.location.href = '/404';
+ if(data === false) {
+ ajaxify.go('404');
return;
}
@@ -168,12 +169,25 @@
if (!templates[tpl_url] || !template_data) return;
document.getElementById('content').innerHTML = templates[tpl_url].parse(JSON.parse(template_data));
- if (callback) callback(true);
+
+ jQuery('#content [template-variable]').each(function(index, element) {
+ templates.set(element.getAttribute('template-variable'), element.value);
+ });
+
+ if (callback) {
+ callback(true);
+ }
}
}
+ templates.get = function(key) {
+ return parsed_variables[key];
+ }
+ templates.set = function(key, value) {
+ parsed_variables[key] = value;
+ }
//modified from https://github.com/psychobunny/dcp.templates
var parse = function(data) {
diff --git a/public/templates/account.tpl b/public/templates/account.tpl
index b04c8572f6..f269317b50 100644
--- a/public/templates/account.tpl
+++ b/public/templates/account.tpl
@@ -69,12 +69,16 @@