diff --git a/guacamole/src/main/webapp/app/index/config/templateRequestDecorator.js b/guacamole/src/main/webapp/app/index/config/templateRequestDecorator.js
index b4c78c754..cb848c3c0 100644
--- a/guacamole/src/main/webapp/app/index/config/templateRequestDecorator.js
+++ b/guacamole/src/main/webapp/app/index/config/templateRequestDecorator.js
@@ -31,6 +31,18 @@ angular.module('index').config(['$provide', function($provide) {
// Required services
var $q = $injector.get('$q');
+ /**
+ * Array of the root elements of all patches which should be applied to
+ * the HTML of retrieved templates.
+ *
+ * @type Element[]
+ */
+ var patches = [
+ $(' HELLO BEFORE HELLO AFTER
HELLO
'); + // Apply all defined patches + angular.forEach(patches, function applyPatch(patch) { + + // Ignore any patches which are malformed + if (patch.tagName !== 'GUAC-PATCH') + return; + + // Insert after any elements which match the "after" + // selector (if defined) + var after = patch.getAttribute('after'); + if (after) + root.find(after).after(patch.innerHTML); + + // Insert before any elements which match the "before" + // selector (if defined) + var before = patch.getAttribute('before'); + if (before) + root.find(before).before(patch.innerHTML); + + // Replace any elements which match the "replace" selector + // (if defined) + var replace = patch.getAttribute('replace'); + if (replace) + root.find(replace).html(patch.innerHTML); + + // Ignore all other attributes + + }); // Transform back into HTML deferred.resolve.call(this, root.html());