Sha256: e59e02dd5fe61946ae35486d8cb9d6a292261921433488c4bf877c286d051555

Contents?: true

Size: 1.4 KB

Versions: 12

Compression:

Stored size: 1.4 KB

Contents

app.factory('TemplateProvider', function($q, $http, $templateCache, $stateParams, Documentation) {
  // creates a template resolver
  return function(defaultTemplate, localTemplates, prefix){
    return {
      resolve: function(name, alt) {
        var deferred = $q.defer();
        var getTemplate = function(customTemplates) {
          var nsIdx;
          while(true) {
            if(customTemplates[prefix] && customTemplates[prefix][name]) {
              deferred.resolve(customTemplates[prefix][name]);
              break;
            } else if (localTemplates[name]) {
              localTemplates[name].then(function(response) {
                deferred.resolve(response.data);
              });
              break;
            } else {
              nsIdx = name.indexOf('::');
              if(nsIdx > 0) {
                name = name.substr(nsIdx + 2);
              } else if(alt) {
                name = alt;
                alt = null;
              } else {
                defaultTemplate.then(function(response) {
                  deferred.resolve(response.data);
                });
                break;
              }
            }
          }
        };

        Documentation.getTemplates($stateParams.version).then(function(response) {
          getTemplate(response.data);
        }, function() {
          getTemplate({});
        });

        return deferred.promise;
      }
    };
  };
});

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
praxis-0.16.1 lib/api_browser/app/js/factories/TemplateProvider.js
praxis-0.16.0 lib/api_browser/app/js/factories/TemplateProvider.js
praxis-0.15.0 lib/api_browser/app/js/factories/TemplateProvider.js
praxis-0.14.0 lib/api_browser/app/js/factories/TemplateProvider.js
praxis-0.13.0 lib/api_browser/app/js/factories/TemplateProvider.js
praxis-0.11.2 lib/api_browser/app/js/factories/TemplateProvider.js
praxis-0.11.1 lib/api_browser/app/js/factories/TemplateProvider.js
praxis-0.11 lib/api_browser/app/js/factories/TemplateProvider.js
praxis-0.11pre lib/api_browser/app/js/factories/TemplateProvider.js
praxis-0.10.1 lib/api_browser/app/js/factories/TemplateProvider.js
praxis-0.10.0 lib/api_browser/app/js/factories/TemplateProvider.js
praxis-0.9 lib/api_browser/app/js/factories/TemplateProvider.js