Skip to content

Instantly share code, notes, and snippets.

@sunsus
Forked from SelrahcD/gist:7042692
Last active September 16, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sunsus/2a5ce3fbe15f447e7fa7 to your computer and use it in GitHub Desktop.
Save sunsus/2a5ce3fbe15f447e7fa7 to your computer and use it in GitHub Desktop.
AngularJs directive for PrismJs
angular.module('ui.prism', []).
directive('uiPrism', [function() {
return {
restrict: 'AE',
replace: 'true',
require: '^ngModel',
template: '<pre class="language-{{scriptLanguage}}" ng-class="{\'line-numbers\':lineNumbers}"><code>{{ngModel}}</code></pre>',
scope: {
ngModel: '=',
scriptLanguage: '=',
lineNumbers: '='
},
link: function (scope, element, attrs){
scope.$watch('data', function(){
element.ready(function() {
Prism.highlightElement(angular.element(element[0]).find("code")[0]);
});
});
}
};
}]
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment