diff options
author | jessib <jessib@riseup.net> | 2014-01-27 10:30:11 -0800 |
---|---|---|
committer | jessib <jessib@riseup.net> | 2014-01-27 10:30:11 -0800 |
commit | 7e0573f3347dca6323eae05127849431ecbceb77 (patch) | |
tree | 8a6ff58fdcc93493b5a8f332350b0a9292119906 /config/initializers | |
parent | 3bfbf0ad20bb5b8e4689fda287cd47738571d10d (diff) | |
parent | d578c07e196cd9758fbf1752a9bb8477c260bb30 (diff) |
Merge branch 'develop' into feature/messages_api
Conflicts:
users/config/locales/en.yml
Diffstat (limited to 'config/initializers')
-rw-r--r-- | config/initializers/markdown_handler.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/config/initializers/markdown_handler.rb b/config/initializers/markdown_handler.rb new file mode 100644 index 0000000..b9e73ba --- /dev/null +++ b/config/initializers/markdown_handler.rb @@ -0,0 +1,19 @@ +# +# This adds support for markdown in views. Just name the template with ".md" +# erb expansion is supported. +# + +require 'rdiscount' + +module MarkdownHandler + def self.erb + @erb ||= ActionView::Template.registered_template_handler(:erb) + end + + def self.call(template) + compiled_source = erb.call(template) + "RDiscount.new(begin;#{compiled_source};end, :generate_toc, :smart, :autolink).to_html" + end +end + +ActionView::Template.register_template_handler :md, MarkdownHandler |