Sha256: 576bf67c0fa99c9ae4d7318b47f55bd22a3bd5ea14f6068d9923b89a86f2dbc9
Contents?: true
Size: 902 Bytes
Versions: 2
Compression:
Stored size: 902 Bytes
Contents
# frozen_string_literal: true ActionView::Base.class_eval do def capture(*args) value = nil buffer = with_output_buffer { value = yield(*args) } # Override to handle Arbo elements inside helper blocks. # See https://github.com/rails/rails/issues/17661 # and https://github.com/rails/rails/pull/18024#commitcomment-8975180 value = value.to_s if value.is_a?(Arbo::Element) if (string = buffer.presence || value) && string.is_a?(String) ERB::Util.html_escape string end end end module Arbo module Rails class TemplateHandler def call(template, source = nil) source = template.source unless source <<-END Arbo::Context.new(assigns, self) { #{source} }.render_in(self).html_safe END end end end end ActionView::Template.register_template_handler :arb, Arbo::Rails::TemplateHandler.new
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
arbo-1.3.0 | lib/arbo/rails/template_handler.rb |
arbo-1.2.0 | lib/arbo/rails/template_handler.rb |