Skip to content

Instantly share code, notes, and snippets.

@jgillich
Created October 12, 2015 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgillich/ef9347b01b6e7e5b89fc to your computer and use it in GitHub Desktop.
Save jgillich/ef9347b01b6e7e5b89fc to your computer and use it in GitHub Desktop.
Hack for Middleman, allows usage of erb in markdown files without the .erb extension.
module Middleman
module CoreExtensions
module Rendering
# Rendering instance methods
module InstanceMethods
def _render_with_all_renderers(path, locs, context, opts, &block)
# Keep rendering template until we've used up all extensions. This
# handles cases like `style.css.sass.erb`
content = nil
### Ugly hack: Always render markdown files as erb templates
if File.extname(path) == ".md"
content = template_data_for_file(path)
path += ".erb"
end
###
while ::Tilt[path]
begin
opts[:template_body] = content if content
content = if block_given?
render_individual_file(path, locs, opts, context, &block)
else
render_individual_file(path, locs, opts, context)
end
path = File.basename(path, File.extname(path))
rescue LocalJumpError
raise "Tried to render a layout (calls yield) at #{path} like it was a template. Non-default layouts need to be in #{source}/#{config[:layouts_dir]}."
end
end
content
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment