Created
June 16, 2014 06:44
-
-
Save alanhoff/8d725278f27db9b59c51 to your computer and use it in GitHub Desktop.
marked.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * angular-marked v0.0.1 | |
| * (c) 2013 J. Harshbarger | |
| * License: MIT | |
| */ | |
| /* jshint undef: true, unused: true */ | |
| /* global angular:true */ | |
| /* global marked:true */ | |
| (function () { | |
| 'use strict'; | |
| var app = angular.module('hc.marked', []); | |
| app.constant('marked', window.marked); | |
| // TODO: filter tests */ | |
| //app.filter('marked', ['marked', function(marked) { | |
| // return marked; | |
| //}]); | |
| app.directive('marked', ['marked', function (marked) { | |
| return { | |
| restrict: 'AE', | |
| replace: true, | |
| scope: { | |
| opts: '=', | |
| marked: '=' | |
| }, | |
| link: function (scope, element, attrs) { | |
| var value = scope.marked || element.text() || ''; | |
| set(value); | |
| function set(val) { | |
| element.html(marked(val || '', scope.opts || null)); | |
| } | |
| if (attrs.marked) { | |
| scope.$watch('marked', set); | |
| } | |
| } | |
| }; | |
| }]); | |
| }()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment