Module: InlineTemplates
- Defined in:
- lib/inline_templates.rb,
lib/inline_templates/builder.rb,
lib/inline_templates/helpers.rb,
lib/inline_templates/version.rb,
lib/inline_templates/blank_object.rb,
lib/inline_templates/buffer_wrapper.rb,
lib/inline_templates/template_handler.rb,
lib/inline_templates/rendering_context.rb
Defined Under Namespace
Modules: Helpers Classes: BlankObject, BufferWrapper, Builder, RenderingContext, TemplateHandler
Constant Summary collapse
- VERSION =
"1.0.0"
Class Method Summary collapse
Class Method Details
.render(view, details, locals, &block) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/inline_templates.rb', line 14 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 |