I have Middleman 3.1.
I am trying to write a helper to which I can pass a string formatted with Markdown that will be rendered into HTML.
Is it possible to use Middleman’s renderer for Markdown to do that?
I have Middleman 3.1.
I am trying to write a helper to which I can pass a string formatted with Markdown that will be rendered into HTML.
Is it possible to use Middleman’s renderer for Markdown to do that?
I got this working so far, but I don’t think I’m using the Markdown engine that would be selected by Middleman:
module FormatHelpers
def markdown(source)
Tilt::KramdownTemplate.new { source }.render
end
end
There’s nothing wrong with that approach, although like you say, you’re explicitly using Kramdown as the engine.
You can retrieve the selected Tilt engine like this:
Tilt['markdown'] # => Tilt::RedcarpetTemplate
Can you show how you’d call this from the template?
Thanks.
remino, never mind. I fgiured it out. I needed the ‘helpers do’ in config.rb.
Your helper fixed my problem. Thanks.
Oops. Didn’t notice replies until now. Sorry, everyone.
Thanks for the tip, @Aupajo.
Glad I could help, @tayknight.