Skip to content

Node.js based forum software built for the modern web

tweaking templates code to accept a template-type attribute (for boolean purposes

Julian Lam51a941b6d5f8
diff --git a/public/src/templates.js b/public/src/templates.js
index 4151d8f823..d81d6aa632 100644
--- a/public/src/templates.js
+++ b/public/src/templates.js
@@ -171,7 +171,18 @@
document.getElementById('content').innerHTML = templates[tpl_url].parse(JSON.parse(template_data));
jQuery('#content [template-variable]').each(function(index, element) {
- templates.set(element.getAttribute('template-variable'), element.value);
+ var value = null;
+
+ switch(element.getAttribute('template-type')) {
+ case 'boolean':
+ value = (element.value === 'true' || element.value === '1') ? true : false;
+ break;
+ default:
+ value = element.value;
+ break;
+ }
+
+ templates.set(element.getAttribute('template-variable'), value);
});
if (callback) {
diff --git a/public/templates/account.tpl b/public/templates/account.tpl
index c85f72bce6..4a288e7bba 100644
--- a/public/templates/account.tpl
+++ b/public/templates/account.tpl
@@ -74,6 +74,6 @@
<input type="hidden" template-variable="yourid" value="{yourid}" />
<input type="hidden" template-variable="theirid" value="{theirid}" />
-<input type="hidden" template-variable="isFriend" value="{isFriend}" />
+<input type="hidden" template-type="boolean" template-variable="isFriend" value="{isFriend}" />
<script type="text/javascript" src="/src/forum/account.js"></script>
\ No newline at end of file