Sha256: afafc908744a9f62389a345e443cb710312e8d386c7b452a56fd54b28863c85f
Contents?: true
Size: 1.12 KB
Versions: 7
Compression:
Stored size: 1.12 KB
Contents
require 'nitro/controller' require 'wee' require 'wee/adaptors/nitro' module Nitro module WeeMixin include Wee::Nitro::ControllerMixin # Returns the output of the component. def component(klass, options = {}) out = '' name = options[:name] || klass.to_s cb = Wee::CallbackRegistry.new(Wee::SequentialIdGenerator.new) rctx = Wee::RenderingContext.new(context(), cb, Wee::HtmlWriter.new(out)) rctx.component_name = name rctx.controller = self rctx.redirect_action = options[:redirect_action] unless c = components[name] unless block = self.class.registered_components[name] block = proc { klass.new } self.class.register_component(name, &block) end make_component name, block.call c = components[name] end raise "Component #{name} not found" if c.nil? c.render(rctx) c.callbacks = cb return out end end # Add Wee-related helper methods to published objects. class Controller include Wee::Nitro::ControllerMixin include WeeMixin end end # * George Moschovitis <gm@navel.gr> # * Michael Neumann <mneumann@ntecs.de>
Version data entries
7 entries across 7 versions & 1 rubygems