2014-11-04 16:02:36 -08:00
|
|
|
/*global define,Promise*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Module defining ExampleDirective. Created by vwoeltje on 11/4/14.
|
|
|
|
*/
|
|
|
|
define(
|
|
|
|
[],
|
|
|
|
function () {
|
|
|
|
"use strict";
|
|
|
|
|
2014-11-05 13:38:43 -08:00
|
|
|
var HAS_EXTENSIONS = "A directive loaded these example extensions.",
|
|
|
|
NO_EXTENSIONS = "A directive tried to load example extensions," +
|
|
|
|
" but found none.";
|
|
|
|
|
2014-11-04 16:02:36 -08:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
*/
|
2014-11-05 12:40:53 -08:00
|
|
|
function ExampleDirective(examples) {
|
|
|
|
// Build up a template from example extensions
|
|
|
|
var template = examples.length > 0 ?
|
2014-11-05 13:38:43 -08:00
|
|
|
HAS_EXTENSIONS : NO_EXTENSIONS;
|
2014-11-05 12:40:53 -08:00
|
|
|
|
2014-11-05 13:38:43 -08:00
|
|
|
template += "<ul>"
|
2014-11-05 12:40:53 -08:00
|
|
|
examples.forEach(function (e) {
|
|
|
|
template += "<li>" + e.text + "</li>";
|
|
|
|
});
|
|
|
|
template += "</ul>";
|
|
|
|
|
2014-11-04 16:02:36 -08:00
|
|
|
return {
|
2014-11-05 12:40:53 -08:00
|
|
|
template: template
|
2014-11-04 16:02:36 -08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return ExampleDirective;
|
|
|
|
}
|
|
|
|
);
|