Sha256: 1864843f1f34b16f48e62ef2d99f4768f8cf3a6393f309fbbe6df0a154924c86
Contents?: true
Size: 1.23 KB
Versions: 4
Compression:
Stored size: 1.23 KB
Contents
require 'nitro/controller' require 'wee' require 'wee/adaptors/nitro' module Nitro # Include this mixin to the standard Controller to have easy # access to Wee Components. module WeeHelper 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 the default Nitro # controller. #++ class Controller include Wee::Nitro::ControllerMixin include WeeHelper end end # * George Moschovitis <gm@navel.gr> # * Michael Neumann <mneumann@ntecs.de>
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
nitro-0.27.0 | lib/nitro/helper/wee.rb |
nitro-0.28.0 | lib/nitro/helper/wee.rb |
nitro-0.29.0 | lib/nitro/helper/wee.rb |
nitro-0.30.0 | lib/nitro/helper/wee.rb |