lib/rdf/rdfa/writer.rb in rdf-rdfa-3.2.0 vs lib/rdf/rdfa/writer.rb in rdf-rdfa-3.2.1

- old
+ new

@@ -73,11 +73,11 @@ # @return [RDF::URI] Base URI used for relativizing URIs attr_accessor :base_uri ## # RDFa Writer options - # @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Writer#options-class_method + # @see https://ruby-rdf.github.io/rdf/RDF/Writer#options-class_method def self.options super + [ RDF::CLI::Option.new( symbol: :lang, datatype: String, @@ -719,10 +719,12 @@ # # @param [String] str # @return [String] # Entity-encoded string def escape_entities(str) + # Haml 6 does escaping + return str if Haml.const_defined?(:Template) CGI.escapeHTML(str).gsub(/[\n\r]/) {|c| '&#x' + c.unpack('h').first + ';'} end # Set the template to use within block # @param [Hash{Symbol => String}] templ template to use for block evaluation; merged in with the existing template. @@ -759,10 +761,16 @@ template = haml_template[template] if template.is_a?(Symbol) template = template.align_left log_debug {"hamlify locals: #{locals.inspect}"} - Haml::Engine.new(template, @options[:haml_options] || HAML_OPTIONS).render(self, locals) do |*args| + haml_opts = @options[:haml_options] || HAML_OPTIONS + haml_runner = if Haml.const_defined?(:Template) + Haml::Template.new(**haml_opts) {template} + else + Haml::Engine.new(template, **haml_opts) + end + haml_runner.render(self, locals) do |*args| yield(*args) if block_given? end rescue Haml::Error => e log_fatal("#{e.inspect}\n" + "rendering #{template}\n" +