Support :plain filter in truffleruby

This commit is contained in:
Takashi Kokubun 2019-09-08 16:56:42 +09:00
parent 3b1d62f7a9
commit a32bbee950
No known key found for this signature in database
GPG Key ID: 6FFC433B12EE23DD
2 changed files with 5 additions and 4 deletions

View File

@ -5,9 +5,6 @@ module Hamlit
class Filters
class Plain < Base
def compile(node)
unless Ripper.respond_to?(:lex)
raise NotImplementedError.new('This platform does not have Ripper.lex required for :plain filter')
end
text = node.value[:text]
text = text.rstrip unless ::Hamlit::HamlUtil.contains_interpolation?(text) # for compatibility
[:multi, *compile_plain(text)]
@ -17,6 +14,10 @@ module Hamlit
def compile_plain(text)
string_literal = ::Hamlit::HamlUtil.unescape_interpolation(text)
unless Ripper.respond_to?(:lex) # truffleruby doesn't have Ripper.lex
return [[:escape, false, [:dynamic, string_literal]]]
end
StringSplitter.compile(string_literal).map do |temple|
type, str = temple
case type

View File

@ -22,5 +22,5 @@ describe Hamlit::Filters do
#{'<script>'}
HAML
end
end if RUBY_ENGINE != 'truffleruby' # truffleruby doesn't have Ripper.lex
end
end