includes/clientside/static/template-compiler.js
changeset 1269 35986c6b2150
parent 1227 bdac73ed481e
child 1280 871f17a0d27d
--- 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;
+}
+