Module: Phlex::DeferredRender

Defined in:
lib/phlex/deferred_render.rb

Overview

Include this module into an HTML or SVG component to make it yield the content block before calling #template.

Examples:

class Tabs < Phlex::HTML
	include DeferredRender

	Tab = Data.define(:name, :content)

	def initialize
		@tabs = []
	end

	def template
		@tabs.each { |t| a { t.name } }
		@tabs.each { |t| article(&t.content) }
	end

	def tab(name, &content)
		@tabs << Tab.new(name, content)
	end
end

Instance Method Summary collapse

Instance Method Details

#templateObject

This method is abstract.

Override to define your own template.

Note:

Phlex::DeferredRender templates do not receive the content block. Instead, it is yielded in advance.



# File 'lib/phlex/deferred_render.rb', line 26