Last active
August 29, 2015 14:10
-
-
Save lachlanjc/a76d869a7fc536244eb6 to your computer and use it in GitHub Desktop.
Render public/ Markdown files into Rails views (great for Terms of Service).
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
def md_file(name) | |
file_contents = File.open(Rails.root + 'public/' + name.to_s).read | |
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, underline: true, space_after_headers: true, strikethrough: true) | |
return markdown.render(file_contents).html_safe | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In your view (assuming
redcarpet
is installed):