Created
October 6, 2013 02:01
A Handlebars Helper for use with my md2hhtml.js gist. This one is written for Ember.js for use in a template like this: {{md2html id="your-id" url="url-to-a-markdown-document"}}
This file contains 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
Em.Handlebars.helper('md2html', function(options){ | |
console.log(options.hash.url); | |
var loading = '<i class="icon-refresh icon-spin icon-4x"></i> Loading...'; | |
var containerHtml = '<div id="'+options.hash.id+'">'+loading+'</div>'; | |
var errorHtml = '<i class="icon-frown icon-4x"></i> There has been an error...'; | |
md2html.get(options.hash.url, function(html){ | |
$('#'+options.hash.id).html(html); | |
}, function(){ | |
$('#'+options.hash.id).html(errorHtml); | |
}); | |
return new Handlebars.SafeString(containerHtml); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This helper assumes the that Font-Awesome is included, but I'm sure it could be altered for use with the standard bootstrap icon library.