Jacob Müller 45d136e327 fix(index): display code example corretly
This commit fixes the displaying of the „name“ template variable (see
screenshot below) in the code example on the front page.

https://goo.gl/qcLf5X
2015-07-01 16:07:41 -07:00

27 lines
778 B
JavaScript

/*
* Code Example Directive
*
* Formats codes examples and prevents
* Angular code from being processed.
*/
angularIO.directive('codeExample', function() {
return {
restrict: 'E',
compile: function(tElement, attrs) {
var html = (attrs.escape === "html") ? _.escape(tElement.html()) : tElement.html();
var classes = 'prettyprint ' + attrs.format + ' lang-' + attrs.language +
(attrs.showcase === 'true' ? ' is-showcase' : '');
var template = '<pre class="' + classes + '">' +
'<code ng-non-bindable>' + html + '</code>' +
'</pre>';
// UPDATE ELEMENT WITH NEW TEMPLATE
tElement.html(template);
// RETURN ELEMENT
return function(scope, element, attrs) {};
}
};
});