Sha256: d2b4eaae4bb69a25ff9c24fa4e463ef19895149dc323de57c616362eff5911ea

Contents?: true

Size: 1.79 KB

Versions: 19

Compression:

Stored size: 1.79 KB

Contents

/**
 * This directive renders out various attributes of types. It will render the description
 * in Markdown and use several dynamic templates to show each piece.
 */
 app.directive('attributeDescription', 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;
          case 'values':
            templatePath = 'views/directives/attribute_description/values.html';
            break;
          case 'member_options':
            templatePath = 'views/directives/attribute_description/member_options.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: _.startCase(name),
              value: option
            };

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

      });
    }
  };
});

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
praxis-2.0.pre.9 lib/api_browser/app/js/directives/attribute_description.js
praxis-2.0.pre.8 lib/api_browser/app/js/directives/attribute_description.js
praxis-2.0.pre.7 lib/api_browser/app/js/directives/attribute_description.js
praxis-2.0.pre.6 lib/api_browser/app/js/directives/attribute_description.js
praxis-2.0.pre.5 lib/api_browser/app/js/directives/attribute_description.js
praxis-2.0.pre.4 lib/api_browser/app/js/directives/attribute_description.js
praxis-2.0.pre.3 lib/api_browser/app/js/directives/attribute_description.js
praxis-2.0.pre.2 lib/api_browser/app/js/directives/attribute_description.js
praxis-2.0.pre.1 lib/api_browser/app/js/directives/attribute_description.js
praxis-0.22.pre.2 lib/api_browser/app/js/directives/attribute_description.js
praxis-0.22.pre.1 lib/api_browser/app/js/directives/attribute_description.js
praxis-0.21 lib/api_browser/app/js/directives/attribute_description.js
praxis-0.20.1 lib/api_browser/app/js/directives/attribute_description.js
praxis-0.20.0 lib/api_browser/app/js/directives/attribute_description.js
praxis-0.19.0 lib/api_browser/app/js/directives/attribute_description.js
praxis-0.18.1 lib/api_browser/app/js/directives/attribute_description.js
praxis-0.18.0 lib/api_browser/app/js/directives/attribute_description.js
praxis-0.17.1 lib/api_browser/app/js/directives/attribute_description.js
praxis-0.17.0 lib/api_browser/app/js/directives/attribute_description.js