Sha256: 1ed5e9eb34ecc8b76def6df334db09cff95111bdb2a459943cf24a210436a05f

Contents?: true

Size: 1.36 KB

Versions: 4

Compression:

Stored size: 1.36 KB

Contents

app.directive('rsAttributeDescription', function($compile, $templateCache, $http) {
  return {
    restrict: 'E',
    templateUrl: 'views/directives/attribute_description.html',
    scope: {
      attribute: '='
    },
    link: function(scope, element) {
      var list = element.find('dl');

      _.forEach(scope.attribute.options, function(option, name) {
        var templatePath = 'views/directives/attribute_description/_default.html';
        var skip_keys = ['reference','dsl_compiler','dsl_compiler_options'];

        switch (name) {
          case 'example':
            // expects string
            if(typeof option !== 'string') {
              option = JSON.stringify(option, null, 2);
            }
            templatePath = 'views/directives/attribute_description/_example.html';
            break;
          case 'headers':
            templatePath = 'views/directives/attribute_description/_headers.html';
            break;
        }

        if( ! _.contains( skip_keys, name ) ) {
          $http.get(templatePath, { cache: $templateCache }).success(function(template) {
            var row = $(template);
            var rowScope = scope.$new(true);

            rowScope.row = {
              name: name,
              value: option
            };

            $compile(row)(rowScope);
            list.append(row);
          });
        }

      });
    }
  };
});

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
praxis-0.16.1 lib/api_browser/app/js/directives/attribute_description.js
praxis-0.16.0 lib/api_browser/app/js/directives/attribute_description.js
praxis-0.15.0 lib/api_browser/app/js/directives/attribute_description.js
praxis-0.14.0 lib/api_browser/app/js/directives/attribute_description.js