Skip to content

Commit

Permalink
Merge pull request #1008 from Futurelearn/seb-rails-6
Browse files Browse the repository at this point in the history
Add support to `Haml::Plugin` for Rails 6
  • Loading branch information
amatsuda committed Mar 15, 2019
2 parents 965c477 + 6eb88c8 commit 9aa0fbe
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/haml/plugin.rb
Expand Up @@ -5,22 +5,24 @@ module Haml
class Plugin
def handles_encoding?; true; end

def compile(template)
def compile(template, source)
options = Haml::Template.options.dup
if template.respond_to?(:type)
options[:mime_type] = template.type
elsif template.respond_to? :mime_type
options[:mime_type] = template.mime_type
end
options[:filename] = template.identifier
Haml::Engine.new(template.source, options).compiler.precompiled_with_ambles(
Haml::Engine.new(source, options).compiler.precompiled_with_ambles(
[],
after_preamble: '@output_buffer = output_buffer ||= ActionView::OutputBuffer.new if defined?(ActionView::OutputBuffer)',
)
end

def self.call(template)
new.compile(template)
def self.call(template, source = nil)
source ||= template.source

new.compile(template, source)
end

def cache_fragment(block, name = {}, options = nil)
Expand Down

0 comments on commit 9aa0fbe

Please sign in to comment.