Added template hooks in the JS template compiler. Attach to thook_<template hook name>. Use Echo() to echo HTML; access compiler instance with Template.tpl_{strings,bool}, etc.
authorDan
Thu, 29 Jul 2010 11:53:15 -0400
changeset 1269 35986c6b2150
parent 1268 57f3857a8161
child 1270 bd3ee7f12bc1
Added template hooks in the JS template compiler. Attach to thook_<template hook name>. Use Echo() to echo HTML; access compiler instance with Template.tpl_{strings,bool}, etc.
includes/clientside/static/template-compiler.js
themes/admin/comment.tpl
themes/enanium/comment.tpl
themes/oxygen/comment.tpl
themes/printable/comment.tpl
themes/stpatty/comment.tpl
--- a/includes/clientside/static/template-compiler.js	Thu Jul 29 11:29:11 2010 -0400
+++ b/includes/clientside/static/template-compiler.js	Thu Jul 29 11:53:15 2010 -0400
@@ -8,6 +8,7 @@
 	this.tpl_bool    = new Object();
 	this.assign_vars = __tpAssignVars;
 	this.assign_bool = __tpAssignBool;
+	this.fetch_hook  = __tpFetchHook;
 	this.run         = __tpRun;
 }
 
@@ -59,6 +60,7 @@
 	code = code.replace(/\<!-- IFSET ([A-z0-9_-]+) --\>([\s\S]*?)\<!-- END \1 --\>/ig, "' + ( ( typeof(this.tpl_strings['$1']) == 'string' ) ? '$2' : '' ) + '");
 	code = code.replace(/\<!-- BEGIN ([A-z0-9_-]+) --\>([\s\S]*?)\<!-- BEGINELSE \1 --\>([\s\S]*?)\<!-- END \1 --\>/ig, "' + ( ( this.tpl_bool['$1'] == true ) ? '$2' : '$3' ) + '");
 	code = code.replace(/\<!-- BEGIN ([A-z0-9_-]+) --\>([\s\S]*?)\<!-- END \1 --\>/ig, "' + ( ( this.tpl_bool['$1'] == true ) ? '$2' : '' ) + '");
+	code = code.replace(/\<!-- HOOK ([A-z0-9_-]+) --\>/ig, "' + this.fetch_hook('$1') + '");
 	return code;
 }
 
@@ -79,3 +81,16 @@
 	return vars;
 }
 
+window.__tpFetchHook = function(hookid)
+{
+	var _ob = '';
+	window.Template = this;
+	window.Echo = function(h)
+	{
+		_ob += h;
+	}
+	eval(setHook('thook_' + hookid));
+	window.Echo = window.Template = false;
+	return _ob;
+}
+
--- a/themes/admin/comment.tpl	Thu Jul 29 11:29:11 2010 -0400
+++ b/themes/admin/comment.tpl	Thu Jul 29 11:53:15 2010 -0400
@@ -19,6 +19,7 @@
 							<!-- END user_has_avatar -->
 						</td>
 					</tr>
+					<!-- HOOK comment_left -->
 					<tr>
 						<td valign="bottom" class="row1<!-- BEGIN is_friend --> row1_green<!-- END is_friend --><!-- BEGIN is_foe --> row1_red<!-- END is_foe -->">
 							{SEND_PM_LINK} {ADD_BUDDY_LINK}
--- a/themes/enanium/comment.tpl	Thu Jul 29 11:29:11 2010 -0400
+++ b/themes/enanium/comment.tpl	Thu Jul 29 11:53:15 2010 -0400
@@ -19,6 +19,7 @@
 							<!-- END user_has_avatar -->
 						</td>
 					</tr>
+					<!-- HOOK comment_left -->
 					<tr>
 						<td valign="bottom" class="row1<!-- BEGIN is_friend --> row1_green<!-- END is_friend --><!-- BEGIN is_foe --> row1_red<!-- END is_foe -->">
 							{SEND_PM_LINK} {ADD_BUDDY_LINK}
--- a/themes/oxygen/comment.tpl	Thu Jul 29 11:29:11 2010 -0400
+++ b/themes/oxygen/comment.tpl	Thu Jul 29 11:53:15 2010 -0400
@@ -19,6 +19,7 @@
 							<!-- END user_has_avatar -->
 						</td>
 					</tr>
+					<!-- HOOK comment_left -->
 					<tr>
 						<td valign="bottom" class="row1<!-- BEGIN is_friend --> row1_green<!-- END is_friend --><!-- BEGIN is_foe --> row1_red<!-- END is_foe -->">
 							{SEND_PM_LINK} {ADD_BUDDY_LINK}
--- a/themes/printable/comment.tpl	Thu Jul 29 11:29:11 2010 -0400
+++ b/themes/printable/comment.tpl	Thu Jul 29 11:53:15 2010 -0400
@@ -19,6 +19,7 @@
 							<!-- END user_has_avatar -->
 						</td>
 					</tr>
+					<!-- HOOK comment_left -->
 					<tr>
 						<td valign="bottom" class="row1<!-- BEGIN is_friend --> row1_green<!-- END is_friend --><!-- BEGIN is_foe --> row1_red<!-- END is_foe -->">
 							{SEND_PM_LINK} {ADD_BUDDY_LINK}
--- a/themes/stpatty/comment.tpl	Thu Jul 29 11:29:11 2010 -0400
+++ b/themes/stpatty/comment.tpl	Thu Jul 29 11:53:15 2010 -0400
@@ -19,6 +19,7 @@
 							<!-- END user_has_avatar -->
 						</td>
 					</tr>
+					<!-- HOOK comment_left -->
 					<tr>
 						<td valign="bottom" class="row1<!-- BEGIN is_friend --> row1_green<!-- END is_friend --><!-- BEGIN is_foe --> row1_red<!-- END is_foe -->">
 							{SEND_PM_LINK} {ADD_BUDDY_LINK}