1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

Resolve set_options API

This commit is contained in:
Takashi Kokubun 2016-10-15 15:22:47 +09:00
parent 94e271bdaf
commit 2406074ac1

View file

@ -7,18 +7,29 @@ require 'hamlit/parser/haml_util'
module Hamlit module Hamlit
class RailsTemplate class RailsTemplate
def call(template) # Compatible with: https://github.com/judofyr/temple/blob/v0.7.7/lib/temple/mixins/options.rb#L15-L24
options = { class << self
def options
@options ||= {
generator: Temple::Generators::RailsOutputBuffer, generator: Temple::Generators::RailsOutputBuffer,
use_html_safe: true, use_html_safe: true,
streaming: true, streaming: true,
buffer_class: 'ActionView::OutputBuffer', buffer_class: 'ActionView::OutputBuffer',
} }
end
def set_options(opts)
options.update(opts)
end
end
def call(template)
options = RailsTemplate.options
# https://github.com/haml/haml/blob/4.0.7/lib/haml/template/plugin.rb#L19-L20 # https://github.com/haml/haml/blob/4.0.7/lib/haml/template/plugin.rb#L19-L20
# https://github.com/haml/haml/blob/4.0.7/lib/haml/options.rb#L228 # https://github.com/haml/haml/blob/4.0.7/lib/haml/options.rb#L228
if template.respond_to?(:type) && template.type == 'text/xml' if template.respond_to?(:type) && template.type == 'text/xml'
options.merge!(format: :xhtml) options = options.merge(format: :xhtml)
end end
Engine.new(options).call(template.source) Engine.new(options).call(template.source)