Created
December 29, 2011 14:36
-
-
Save chooh/1534361 to your computer and use it in GitHub Desktop.
Markdown handler with erb support
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
# put me in config/initializers/rdiscount.rb | |
class ActionView::Template | |
class RDiscountHandler < Handler | |
def self.erb_handler | |
@@erb_handler ||= ActionView::Template.registered_template_handler(:erb) | |
end | |
def self.call(template) | |
compiled_source = erb_handler.call(template) | |
"::RDiscount.new(begin;#{compiled_source};end).to_html" | |
end | |
end | |
register_template_handler :markdown, RDiscountHandler | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment