code: function compileTemplate(name) {
          // Directive compile function
          return function (tElement, tAttrs, transclude) {
              var rootElement = document.createElement("div");
              Object.keys(tAttrs).forEach(function (key) {
                  if (key[0] !== '$') {
                      rootElement.setAttribute(key, tAttrs[key]);
                  }
              });
              var immediateToken;
              // Directive link function
              return function ($scope, elements, attrs, parents) {
                  var parent = parents.reduce(function (found, item) { return found || item; });
                  parent[name] = function (itemPromise) {
                      // Actual item renderer
                      return WinJS.Promise.as(itemPromise).then(function (item) {
                          var itemScope = $scope.$new();
                          itemScope.item = item;
                          var result = rootElement.cloneNode(false);
                          transclude(itemScope, function (clonedElement) {
                              for (var i = 0, len = clonedElement.length; i < len; i++) {
                                  result.appendChild(clonedElement[i]);
                              }
                          });
                          WinJS.Utilities.markDisposable(result, function () {
                              itemScope.$destroy();
                          });
                          immediateToken = immediateToken || setImmediate(function () {
                              immediateToken = null;
                              itemScope.$apply();
                          });
                          return result;
                      })
                  };
              };
          };
      }
docs: Shared compile/link functions