Sha256: 11d8e7fff1412ada8643b9b72f1150a60b8c1c7f24e93f0dc4d962c9ae9eeda7
Contents?: true
Size: 1.16 KB
Versions: 4
Compression:
Stored size: 1.16 KB
Contents
require "active_support" require "action_view" require "inline_templates/version" require "inline_templates/builder" require "inline_templates/blank_object" require "inline_templates/buffer_wrapper" require "inline_templates/rendering_context" require "inline_templates/helpers" require "inline_templates/template_handler.rb" module InlineTemplates def self.render(view, details, locals, &block) identifier = "(inline:#{block.inspect})" handler = ->(template) do method_name = nil template.instance_exec do method_name = self.method_name view.singleton_class.send :define_method, "#{method_name}_block" do block end end <<-EOF @output_buffer ||= ActionView::OutputBuffer.new context = ::InlineTemplates::RenderingContext.new(self, local_assigns, ::InlineTemplates::Builder.new) context.instance_exec &self.#{method_name}_block @output_buffer.to_s EOF end template = ActionView::Template.new("", identifier, handler, details) template.render view, locals end end ActionView::Template.register_template_handler :rit, InlineTemplates::TemplateHandler.new
Version data entries
4 entries across 4 versions & 1 rubygems