An Angular directive for including external markdown files

This angular directive includes external markdown files, compiling them to HTML at runtime using marked.js.

I coded this as part of my notCMS.js project - which aims to offer basic content editing functionality via external markdown files to statically hosted (GitHub, DropBpox) websites.

<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>An Angular directive for including external markdown files</title>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/marked/0.3.0/marked.js"></script>

    <script type='text/javascript'>
        //<![CDATA[ 

        var app = angular.module('myApp', []);

        app.directive('markdown', ['$compile', '$http', '$templateCache',
            function($compile, $http, $templateCache) {
                return {
                    restrict: 'AE',
                    replace: true,
                    transclude: false,
                    compile: function(elem, attr) {
                        templateLoader = $http.get(attr.src, {
                            cache: $templateCache
                        })
                        .success(function(md) {
                            elem.html(marked(md));
                        })
                        .error(function(md) {
                            errStr = 'An error occurred processing markdown file <a target="_blank" href="' + attr.src + '">' + attr.src + '</a>: ' + md;
                            console.log(errStr);
                            elem.html(errStr);
                        })
                        ;
                    }
                };
            }
        ])

         //]]>
    </script>

</head>

<body ng-app="myApp">
    <markdown src="copy_1.md">This content will be replaced my markdown</markdown>
    n
    <p markdown src="copy_2.md" />

    <div markdown src="copy_3.md" />
</body>

</html>

Demo here - http://ianscrivener.com/markdown-include-angular-directive/

Soucrecocde here - https://github.com/ianscrivener/markdown-include-angular-directive