module Phlex::Kit

def const_added(name)

def const_added(name)
	return if autoload?(name)
	me = self
	constant = const_get(name)
	if Class === constant && constant < Phlex::SGML
		constant.include(self)
		define_method(name) do |*args, **kwargs, &block|
			constant = me.const_get(name)
			render(constant.new(*args, **kwargs), &block)
		end
		define_singleton_method(name) do |*args, **kwargs, &block|
			if (component = Fiber[:__phlex_component__])
				component.instance_exec do
					render(constant.new(*args, **kwargs), &block)
				end
			else
				raise "You can't call `#{name}' outside of a Phlex rendering context."
			end
		end
	end
	super
end