Skip to content

Instantly share code, notes, and snippets.

@ntrepid8
Created October 6, 2013 02:01
Show Gist options
  • Save ntrepid8/6848493 to your computer and use it in GitHub Desktop.
Save ntrepid8/6848493 to your computer and use it in GitHub Desktop.
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"}}
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);
});
@ntrepid8
Copy link
Author

ntrepid8 commented Oct 6, 2013

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment