Sha256: 9bc804ea819c35078574ab7596a8283286f789153f266394638d56f7ed4803cb
Contents?: true
Size: 992 Bytes
Versions: 1
Compression:
Stored size: 992 Bytes
Contents
# frozen_string_literal: true ActionView::Base.class_eval do def capture(*args) value = nil buffer = with_output_buffer { value = yield(*args) } case string = buffer.presence || value when ActionView::OutputBuffer string.to_s when ActiveSupport::SafeBuffer string when Arbo::Element # 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.render_in when 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
arbo-1.3.1 | lib/arbo/rails/template_handler.rb |